CN117501247A - Data storage method and related equipment - Google Patents

Data storage method and related equipment Download PDF

Info

Publication number
CN117501247A
CN117501247A CN202180099157.2A CN202180099157A CN117501247A CN 117501247 A CN117501247 A CN 117501247A CN 202180099157 A CN202180099157 A CN 202180099157A CN 117501247 A CN117501247 A CN 117501247A
Authority
CN
China
Prior art keywords
memory
storage
data
unit
area
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
CN202180099157.2A
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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Publication of CN117501247A publication Critical patent/CN117501247A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a data storage method and related equipment. The data storage method is applied to electronic equipment, the electronic equipment comprises a first memory and a second memory, the second memory comprises a first memory unit and a second memory unit, the first memory is a volatile memory, the first memory unit is a volatile memory unit, and the second memory unit is a nonvolatile memory unit; the method comprises the following steps: generating a write instruction; after writing the target data into the first storage unit based on the writing instruction, keeping the target data in a backup area of the first memory; when the first storage unit in the second memory is reset, part or all of data in the backup area is rewritten into the first storage unit; and writing the data written into the first storage unit into the second storage unit. By implementing the embodiment of the application, the data loss of the volatile memory after reset can be avoided.

Description

Data storage method and related equipment Technical Field
The present disclosure relates to the field of information technologies, and in particular, to a data storage method and related devices.
Background
With the continuous improvement of the storage density technology of flash memory particles such as NAND flash, one memory cell (cell) can store more and more data, that is, the storage cost per unit data is lower and lower, but with the memory density technology, more memory devices corresponding to the memory devices store abnormal memory, and more complex software technology.
From the architecture inside modern memory devices, in order to improve the read/write performance of the memory device, a volatile storage medium (e.g., a random access memory (Random Access Memory, RAM) buffer) is typically provided before a nonvolatile storage medium (e.g., NAND). Thus, write requests from a System On Chip (SOC) can be buffered in the volatile storage medium before being asynchronously written back to the non-volatile storage medium. When the memory device is abnormal, the most effective means is to reset the memory device, however, because the buffer is composed of volatile storage media, when the memory device is abnormally reset, the data in the volatile storage media is lost, and the loss of users is caused.
Therefore, how to avoid the data loss after the reset of the memory device is a problem to be solved in the present application.
Disclosure of Invention
The embodiment of the application provides a data storage method and related equipment, so as to avoid data loss after memory reset.
In a first aspect, an embodiment of the present application provides a data storage method, which is characterized in that the data storage method is applied to an electronic device, where the electronic device includes a first memory and a second memory, the second memory includes a first storage unit and a second storage unit, the first memory is a volatile memory, the first storage unit is a volatile storage unit, and the second storage unit is a nonvolatile storage unit; the method may comprise:
generating a write instruction, wherein the write instruction is used for indicating to write target data in the first memory into the second memory; after the target data is written into the first storage unit based on the writing instruction, the target data is reserved in a backup area of the first memory; when the first storage unit in the second memory is reset, rewriting part or all of the data in the backup area to the first storage unit; and writing the data written into the first storage unit into the second storage unit.
When the embodiment of the method of the first aspect is implemented, when data is stored, after the data is written into the second memory, the data which needs to be erased is stored in the backup area of the first memory, and part or all of the data in the backup area can be sent to the second memory again (the data is rewritten into the first memory unit) under the condition that the second memory is reset (at this time, the data in the first memory unit is lost during the resetting), so that the data loss in the first memory unit after the second memory is reset can be avoided. Moreover, the data of the resending backup area can keep the consistency of the metadata after abnormal recovery, and the loss of the actual file data of the user is avoided. In addition, the method does not need to restart the electronic equipment, so that the user experience is greatly improved. Therefore, the data to be written in is backed up when the data is written, so that the data can be acquired again when the data is lost, and the data loss of a user is avoided to the greatest extent.
In one possible implementation, the first memory includes a storage area and the backup area, and the storage area is used for storing the target data; the retaining the target data in the backup area of the first memory includes: and storing the target data from the storage area to the backup area, and releasing the target data in the storage area. In this embodiment of the present application, the first memory includes a storage area for storing target data to be written into the second memory, and a backup area for storing backup data of the target data. The target data to be written into the second memory is saved from the memory area to the backup area while the target data in the original memory area is released (i.e., erased) so that the original memory area can be rewritten with new data. When the second memory is reset, part or all of the data in the backup area is sent to the second memory again, so that the data loss of the second memory after the reset can be avoided.
In one possible implementation, the first memory includes a storage area and the backup area, and the storage area is used for storing the target data; the retaining the target data in the backup area of the first memory includes: the target data in the storage area is not released and the storage area is added to the backup area. In this embodiment of the present application, the first memory includes a storage area for storing target data to be written into the second memory, and a backup area for storing backup data of the target data. After the target data in the storage area is written into the second memory, the data in the storage area is not released, but the storage area is added into the backup area, that is, the original storage area becomes the backup area, and new data cannot be rewritten. In the scheme, the target data can be backed up without being referenced or copied again, so that the data loss after the second memory is reset is avoided, and meanwhile, the hardware computing resources are greatly saved.
In one possible implementation, the not releasing the target data in the storage area and adding the storage area to the backup area includes: and adding 1 on the basis of the current reference number of the storage area, and adding the storage area into the backup area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0. In the embodiment of the application, the number of times of reference to the target data in the storage area is increased after the write instruction is completed, so that the data in the storage area is ensured not to be released, and the target data can be ensured to be rewritten into the second memory after the second memory is reset.
In one possible implementation, before generating the write instruction, the method further includes: and increasing 1 on the basis of the current reference number of the storage area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0. In the embodiment of the application, before the write instruction is generated, the number of references corresponding to all storage areas available for storing the target data in the first memory is increased by 1, so that the target data in the storage areas is written by increasing the number of references to the target data in the storage areas after the write instruction is completed, the data in the storage areas are ensured not to be released, and the target data can be ensured to be rewritten in the second memory after the second memory is reset.
In one possible implementation, the storage space of the backup area is greater than or equal to the storage space of the first storage unit. In the embodiment of the application, the storage space of the backup area in the first memory is not smaller than the storage space in the first storage unit, so that the lost data in the first storage unit can be completely retrieved from the data in the backup area after the first storage unit is reset, and the loss of the data is avoided.
In one possible implementation, the method further includes: and when the size of the stored data in the backup area exceeds a storage threshold value, releasing the target data stored in the backup area earliest. In this embodiment of the present application, when the size of the storage data of the backup area in the first memory exceeds a storage threshold (e.g., the storage size of the first storage unit), the data stored in the backup area at the earliest has been written into the second storage unit by the first storage unit, and since the second storage unit is a nonvolatile storage unit, the data is not lost even when the second memory is reset. Therefore, when the storage threshold is exceeded, the earliest reserved target data in the current backup area is released, so that the storage pressure in the first memory can be relieved, and the storage space in the first memory is ensured.
In one possible implementation, the method further includes: and when the size of the stored data in the backup area exceeds a storage threshold value, releasing the target storage area which is earliest entering the backup area and the data in the target storage area. In this embodiment of the present application, when the size of the stored data of the backup area in the first memory exceeds a storage threshold (e.g., the storage size of the first memory unit), the data stored in the storage area that is added to the backup area at the earliest has been written into the second memory unit by the first memory unit, and since the second memory unit is a nonvolatile memory unit, the data is not lost even when the second memory is reset. Therefore, when the storage threshold is exceeded, the storage area (i.e., new data can be rewritten) that is added to the backup area earliest in the current backup area, and the data in the storage area are released, so that the storage pressure in the first memory can be relieved, and the storage space in the first memory can be ensured.
In one possible implementation, the method further includes: generating an output instruction when receiving a notification of insufficient storable space of the first memory, wherein the output instruction is used for indicating that all data in the first memory unit is written into the second memory unit; and after all the data in the first storage unit are written into the second storage unit, releasing all the storage areas in the backup area and the data in all the storage areas. In this embodiment of the present application, when the storable space of the first memory is insufficient (the memory is tensed), an output instruction (e.g., a flush command) may be issued to the second memory device, so that all the data of the first memory unit in the second memory is written into the second memory unit. After all the data are written into the second storage unit, all the storage areas in the backup area and the data in all the storage areas can be released so as to relieve the memory pressure.
In a second aspect, an embodiment of the present application provides a data storage device, which is applied to an electronic device, where the electronic device includes a first memory and a second memory, the second memory includes a first storage unit and a second storage unit, the first memory is a volatile memory, the first storage unit is a volatile memory, and the second storage unit is a nonvolatile memory; the device comprises: a generating unit configured to generate a write instruction for instructing writing of target data in the first memory into the second memory; the backup unit is used for keeping the target data in a backup area of the first memory after the target data is written into the first storage unit based on the writing instruction; a first writing unit, configured to, when the first storage unit in the second memory is reset, rewrite part or all of the data in the backup area to the first storage unit; and the second writing unit is used for writing the data written into the first storage unit into the second storage unit.
In one possible implementation, the first memory includes a storage area and the backup area, and the storage area is used for storing the target data; the backup unit is specifically configured to: and storing the target data from the storage area to the backup area, and releasing the target data in the storage area.
In one possible implementation, the first memory includes a storage area and the backup area, and the storage area is used for storing the target data; the backup unit is specifically configured to: the target data in the storage area is not released and the storage area is added to the backup area.
In one possible implementation manner, the backup unit is specifically configured to: and adding 1 on the basis of the current reference number of the storage area, and adding the storage area into the backup area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0.
In one possible implementation, the apparatus further includes: and a reference management unit configured to increase 1 on the basis of the current reference number of the storage area before the write instruction is generated, where the reference count is used to indicate the number of times the target data in the storage area is referenced, and when the reference number of times of the storage area is 0, the target data in the storage area is released.
In one possible implementation, the storage space of the backup area is greater than or equal to the storage space of the first storage unit.
In one possible implementation, the apparatus further includes: and the first releasing unit is used for releasing the target data stored in the backup area earliest when the size of the stored data in the backup area exceeds a storage threshold value.
In one possible implementation, the apparatus further includes: and the second releasing unit is used for releasing the target storage area which is earliest to enter the backup area and the data in the target storage area when the size of the stored data in the backup area exceeds a storage threshold value.
In one possible implementation, the apparatus further includes: the output unit is used for generating an output instruction when receiving the notification of insufficient storage space of the first memory, wherein the output instruction is used for indicating that all data in the first storage unit are written into the second storage unit; and the third releasing unit is used for releasing all the storage areas in the backup area and the data in all the storage areas after all the data in the first storage unit are written into the second storage unit.
In a third aspect, an embodiment of the present application provides a data storage device, which is applied to an electronic device, where the electronic device includes a first memory and a second memory, the second memory includes a first storage unit and a second storage unit, the first memory is a volatile memory, the first storage unit is a volatile memory, and the second storage unit is a nonvolatile memory; the apparatus comprises a processor configured to support the electronic device to implement the corresponding functions in the data storage method provided in the first aspect.
In a fourth aspect, embodiments of the present application provide an electronic device comprising a processor, a first memory, and a second memory, the processor coupled to the first memory and the second memory; the second memory comprises a first memory unit and a second memory unit, the first memory is a volatile memory, the first memory unit is a volatile memory unit, and the second memory unit is a nonvolatile memory unit; the first memory or the memory coupled with the processor stores necessary program instructions and data of the electronic device, so that the electronic device realizes the corresponding functions in the data storage method provided in the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program comprising instructions which, when executed by a computer, cause the computer to perform the process performed by the data storage device in the second aspect described above.
In a sixth aspect, embodiments of the present application provide a computer readable storage medium storing computer software instructions for use with a data storage device provided in the second aspect, including a program designed to execute the above aspect.
Drawings
In order to more clearly describe the technical solutions in the embodiments or the background of the present application, the following description will describe the drawings that are required to be used in the embodiments or the background of the present application.
Fig. 1 is a schematic diagram of several memory cells according to an embodiment of the present application.
Fig. 2 is a schematic structural diagram of a memory device according to an embodiment of the present application.
FIG. 3 is a schematic diagram of a data storage system according to an embodiment of the present application.
Fig. 4 is a schematic structural diagram of a data storage device according to an embodiment of the present application.
FIG. 5 is a schematic diagram of copying target data into a first store according to an embodiment of the present application.
Fig. 6 is a schematic diagram of writing back target data from a first memory to a second memory according to an embodiment of the present application.
Fig. 7 is a schematic diagram of retaining data in a backup area according to an embodiment of the present application.
Fig. 8 is a schematic diagram of releasing target data in a storage area in the prior art according to an embodiment of the present application.
Fig. 9 is a schematic diagram of managing backup areas according to an embodiment of the present application.
Fig. 10 is a schematic diagram of another management backup area according to an embodiment of the present application.
Fig. 11 is a schematic diagram of rewriting target data into a second memory according to an embodiment of the present application.
Fig. 12 is a flowchart of a data storage method according to an embodiment of the present application.
Fig. 13 is a schematic structural diagram of a data storage meter device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application.
The terms first and second and the like in the description and in the claims of the present application and in the drawings are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
It should be understood that in this application, "at least one" means one or more, and "a plurality" means two or more. "and/or" for describing the association relationship of the association object, the representation may have three relationships, for example, "a and/or B" may represent: only a, only B and both a and B are present, wherein a, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship. "at least one of" or the like means any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one (one) of a, b or c may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the present application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
As used in this specification, the terms "component," "module," "system," and the like are intended to refer to a computer-related entity, either hardware, firmware, a combination of hardware and software, or software in execution. For example, a component may be, but is not limited to being, a process running on a processor, an object, an executable, a thread of execution, a program, and/or a computer. By way of illustration, both an application running on a computing device and the computing device can be a component. One or more components may reside within a process and/or thread of execution and a component may be localized on one computer and/or distributed between 2 or more computers. Furthermore, these components can execute from various computer readable media having various data structures stored thereon. The components may communicate by way of local and/or remote processes such as in accordance with a signal having one or more data packets (e.g., data from two components interacting with one another in a local system, distributed system, and/or across a network such as the internet with other systems by way of the signal).
First, some terms in this application are explained for easy understanding by those skilled in the art.
(1) NAND Flash (NAND Flash) is a nonvolatile memory technology. The storage unit of the NAND Flash is divided into cells, die, blocks, pages, cells and the like. A cell is the smallest memory cell, and a plurality of cells form a page; multiple pages form a block; multiple blocks constitute one die. The NAND Flash has the following hardware characteristics besides the characteristic of still storing data after power failure: a memory cell is written (program) to indicate that data can be changed from a logic 1 to a logic 0, but the cell can no longer be returned to a logic 1 by writing, and then the memory cell can be returned to a logic 1 by erasing (erase). The smallest unit of erase in a typical flash memory is called a block.
(2) The solid state drive (Solid State Drive, SSD), or solid state disk, is a hard disk made from an array of solid state electronic memory chips. SSD is made up of control unit and memory cell (Flash chip, DRAM chip), its working temperature range of the chip is very wide, the application field is extensive. The storage media of the solid state disk are generally two types, one is to use a Flash memory (Flash chip) as the storage medium, and the other is to use a DRAM as the storage medium. Its appearance can be made in a variety of patterns, for example: notebook hard disk, micro hard disk, memory card, U disk, etc.
(3) Double Rate ddr=double Data Rate, double Rate synchronous dynamic random access memory=ddr SDRAM, commonly referred to as DDR, where SDRAM is an abbreviation for (Synchronous Dynamic Random Access Memory), i.e. synchronous dynamic random access memory, and DDR SDRAM is an abbreviation for Double Data Rate SDRAM, meaning Double Rate synchronous dynamic random access memory. DDR memory is developed on the basis of SDRAM memory, and SDRAM production system is still used, so that for memory manufacturers, DDR memory production can be realized by only slightly improving equipment for manufacturing common SDRAM, and cost can be effectively reduced.
At present, with the continuous improvement of storage density technologies of flash memory particles such as NAND flash, one memory cell (cell) can store more and more data, that is, the storage cost per unit data is continuously reduced. For example: referring to fig. 1, fig. 1 is a schematic diagram of several memory cells according to an embodiment of the present application. As shown in fig. 1, flash memory particles of most memory devices may be classified into Single-Level cells (SLC), double-Level cells (MLC), triple-Level cells (TLC), and quad-Level cells (QLC), and even Multi-Level cells may occur; wherein, each storage unit of STC can save 1bit data, each storage unit of MTC can save 2 bits data, each storage unit of TTC can save 3 bits data, and each storage unit of QTC can save 4 bits data.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a memory device according to an embodiment of the present application. As shown in fig. 2, from the current architecture inside the memory device, in order to improve the read/write performance of the memory device, a Random Access Memory (RAM) buffer (buffer) is generally disposed before the NAND medium. Thus, write instructions from a System On Chip (SOC) can be buffered in this buffer before being written back asynchronously into the NAND. When the memory device is abnormal, the most effective means is to reset the memory device. However, since this buffer is a volatile RAM composition, data in the buffer is lost when the memory device is reset due to an abnormality.
In the prior art, in order to avoid data loss, one way is to let the memory device write back all the data in the buffer to the NAND, i.e. send a flush command to the memory device, before the memory device is reset. However, when the memory device is abnormal, it may not be able to process any command, i.e. when the memory device is abnormal, the data in the buffer cannot be refreshed on the NAND medium in response to the command, and only the lost data is reset. Alternatively, once the memory device is found to be unable to respond to any command, the host and memory device are reset simultaneously. And when the host is started, the consistency of the metadata is protected by the abnormal recovery when the file system is mounted. By the method, the influence of the lost data on the file system mounting can be avoided, but the loss of the actual file data of the user cannot be avoided, and the use experience can be obviously influenced.
Therefore, the embodiment of the application can provide the data storage method and the related equipment for avoiding data loss during resetting of the storage device, and the method has small influence on a user and improves the user experience.
One of the system architectures on which the embodiments of the present application are based is described below.
Based on the foregoing, embodiments of the present application provide a data storage system architecture including a host and an associated storage device. Referring to fig. 3, fig. 3 is a schematic diagram of a data storage system architecture according to an embodiment of the present application. As shown in fig. 3, the data storage system architecture includes a host (host) 100 and a second memory 103. The host 100 may be any computing device that generates data, such as a server, a personal computer, a tablet, a mobile phone, a personal digital assistant, a smart wearable device, etc.; the host 100 further includes a processing unit 101 and a first memory 102. The secondary storage 103 (corresponding to the storage device described above) may be any storage that provides storage/read data functionality for the host 100. In the embodiment of the present application, the second memory 103 and the host 100 may be located in one electronic device, or may be located in a different electronic device, which is not limited in this application. The host 100 or the second memory 103 may be a chip or a chipset or a circuit board carrying a chip or a chipset, which may be operated under the necessary software driving. In particular, the method comprises the steps of,
The host 100 may include a processing unit (central processing unit, CPU) 101 and a first memory 102. Alternatively, all physical devices on the application processing side, such as power supplies, other input-output controllers, and interfaces, which are not shown in fig. 3, may be included. Wherein,
processing unit 101: a file system (e.g., flash file system F2 FS), an operating system or related applications, etc., may be run to control the various hardware or software elements connected to the processing unit 101, and may process various data and perform operations. For example: the processing unit 101 may execute a file system to issue related read-after-write erase instructions.
Optionally, the processing unit 101 may include one or more of a Central Processing Unit (CPU), an application processing unit (application processor, AP), a modem processing unit, a graphics processing unit (graphics processing unit, GPU), an image signal processing unit (image signal processor, ISP), a video codec unit, a digital signal processing unit (digital signal processor, DSP), a baseband processing unit, and a neural network processing unit (neural-network processing unit, NPU), etc. The processing unit 101 may comprise one or more arithmetic processing units (also referred to as processing cores), wherein different arithmetic processing units may be separate devices or may be integrated in one or more devices. Optionally, a memory may be provided in the processing unit 101 for storing relevant instructions and data. In some embodiments, the memory in processing unit 101 is a Cache (Cache). The Cache may hold instructions or data that has just been used or recycled by processing unit 101. If the processing unit 101 needs to reuse the instruction or data, it can be called directly from the Cache. Repeated accesses are avoided and the latency of the processing unit 101 is reduced, thus improving the efficiency of the system. Further, the processing unit 101 may also be implemented as a System on Chip (SoC).
In addition, in the embodiment of the present application, the processing unit 101 may generate a write instruction, where the write instruction is used to instruct to write the target data in the first memory 102 into the second memory 103; after writing the target data to the first storage unit 1031 based on the write instruction, retaining the target data in the backup area 1022 of the first memory 102; when the first storage unit 1031 in the second memory 103 is reset, part or all of the data in the backup area 1022 is rewritten to the first storage unit 1031; the data written in the first storage unit 1031 is written in the second storage unit 1032. The processing unit 101 may load the instructions or data stored in the second memory 103 into the first memory 102, and transfer the instructions or data to be operated to the processing unit 101 for operation, and when the operation is completed, the processing unit 101 temporarily stores the result in the first memory 102, and may store the instructions or data to be stored in the second memory 103 for a long period of time. In addition, the specific implementation process of this solution may refer to the following related descriptions of the embodiments, which are not described herein for brevity.
The first Memory 102, which may also be referred to as a Memory (Memory) or an internal Memory, is a volatile Memory. The first memory 102 in this embodiment of the present application includes a readable and writable running memory, which may be used to temporarily store operation data in the processing unit 101, and interact data with the second memory 103 or other external memories, and may be used as a storage medium for temporary data, such as file systems or other running programs. For example, the file system running on the processing unit 101 transfers the data to be operated from the first memory 102 to the processing unit 101 for operation, and when the operation is completed, the processing unit 101 transfers the result.
Optionally, the first memory 102 includes a storage area 1021 and a backup area 1022. The storage area 1021 is used to store temporary data or programs of instructions for the file system or other program in operation. The backup area 1022 is used to store data stored from the storage area 1021 into the second memory 103.
It should be noted that, the first memory 102 may include a plurality of blocks (blocks), each Block includes a plurality of pages (pages), and each Page includes a certain number of cells (cells), where the blocks, pages, and cells are all used for storing data, and the Page cache Page is the smallest addressing unit, i.e. the smallest unit of reading/writing. Accordingly, the storage area 1021 in the first memory 102 includes one or more page buffers for receiving read/write instructions, reading or storing data. The backup area 1022 also contains one or more page caches for backing up data of the storage area that is responsive to the write command. Therefore, the storage area 1021 and the backup area 1022 in the first memory 102 may correspond to a single page buffer, may correspond to a block composed of a plurality of page buffers, and may correspond to an area for storing data composed of a plurality of blocks, and the composition of the storage area 1021 and the backup area 1022 is not particularly limited in this application.
It should be noted that when all cells in all pages in all blocks of the first memory are single-level cells (SLC), the first memory forms an SLC type memory. Similarly, when all cells in all pages in all blocks of the first memory are multi-level cell (MLC) or tri-level cell (TLC), the first memory thus forms a MLC/TLC type memory.
In addition, the first memory 102 may be one or more of Dynamic Random Access Memory (DRAM), static Random Access Memory (SRAM), synchronous Dynamic Random Access Memory (SDRAM), and the like. The DRAM further includes a double-rate synchronous dynamic random access memory (Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM) abbreviated as DDR, a second-generation double-rate synchronous dynamic random access memory (DDR 2), a third-generation double-rate synchronous dynamic random access memory (DDR 3), a fourth-generation low-power-consumption double-data-rate synchronous dynamic random access memory (Low Power Double Data Rate, lpddr 4), a fifth-generation low-power-consumption double-data-rate synchronous dynamic random access memory (Low Power Double Data Rate, lpddr 5), and the like, which are not particularly limited in the embodiments of the present application.
The second memory 103 (e.g., the memory device mentioned above with reference to fig. 2) includes a first memory cell (e.g., the buffer mentioned above with reference to fig. 2), which is a volatile memory cell, and a second memory cell (e.g., the flash NAND mentioned above with reference to fig. 2), which is a nonvolatile memory cell; includes a first memory unit 1031 for asynchronously writing received data into a second memory unit 1032; the second storage unit 1032 may be used to store long-term instructions and data, such as boot programs, operating systems, application programs, data, etc., involved in the operation of the host 100.
Optionally, the second memory 103 may be one or more of Flash memory (for example, NAND Flash memory, NOR Flash memory, etc.), universal Flash memory (universal Flash storage, UFS), embedded multimedia card eMMC, universal Flash memory multi-chip package uMCP memory, embedded multimedia card multi-chip package eMCP memory, solid State Drive (SSD), etc., which is not specifically limited in this embodiment.
When the data is stored, after the data is written into the second memory, the data which needs to be erased originally is stored in the backup area of the first memory. In the case where the second memory is reset (at this time, the data in the volatile memory unit (i.e., the first memory unit) is lost during the reset), part or all of the data in the backup area is sent to the second memory again (the data is rewritten to the first memory unit), so that the data loss in the first memory unit after the second memory is reset can be avoided.
It is understood that the structure of the host 100 or the second memory 103 in fig. 3 is only some exemplary implementations provided in the embodiments of the present application, and the structure of the host 100 or the second memory 103 in the embodiments of the present application includes, but is not limited to, the above implementation.
It is further understood that the processing unit 101 and the first memory 102, and the host 100 and the second memory 103 may communicate with each other through a system bus, or may communicate through other connection manners, which is not specifically limited in the embodiment of the present application. The structure illustrated in the embodiment of the present application does not constitute a specific limitation of the host 100 or the second memory 103. In other embodiments of the present application, the host 100 or the second memory 103 may include more or less components than illustrated, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a data storage device according to the embodiment of the present application, where the data storage device mainly uses the host 100 as a main body, and is described from the perspective that the processing unit 101 writes data into the second memory 103. The data storage method provided by the application can be applied to the system architecture shown in the figure 3, and data loss during resetting of the storage device is avoided. Wherein the processing unit 101 includes: a file system, a write data backup module 101, a backup area management module 102, and an abnormal retransmission module 103; the second memory 103 includes: a first storage unit 1031 and a second storage unit 1032. Wherein,
The processing unit 101 is configured to generate a write instruction; after writing the target data into the first storage unit based on the writing instruction, keeping the target data in a backup area of the first memory; when the first storage unit in the second memory is reset, part or all of data in the backup area is rewritten into the first storage unit; and writing the data written into the first storage unit into the second storage unit.
Wherein the file system: for generating a write instruction for instructing writing of target data in the first memory 102 into the second memory 103. For example: referring to fig. 5 and fig. 6, fig. 5 is a schematic diagram of copying target data into a first memory according to an embodiment of the present application, and fig. 6 is a schematic diagram of writing target data back from a first memory into a second memory according to an embodiment of the present application. As shown in fig. 5, target data (e.g., user data) is first copied or allocated to a page buffer of a storage area in the first memory 102 in response to a write instruction. As shown in fig. 6, the target data written into the page buffer of the storage area is written back into the second memory 103 to complete the write instruction.
Write data backup module 101: for retaining the target data in the first memory 102 in the backup area of the first memory 102 after the write instruction is completed, that is, after the target data in the first memory 102 is written into the first storage unit 1031 in the second memory 103, it is possible to avoid the target data in the first memory 102 from being released. For example: referring to fig. 7 and fig. 8, fig. 7 is a schematic diagram of retaining data in a backup area according to an embodiment of the present application, and fig. 8 is a schematic diagram of releasing target data in a storage area according to an embodiment of the present application in the prior art. As shown in fig. 7, after the data in the page buffer of the storage area is written into the storage device, the target data in the page buffer of the storage area is retained in the page buffer of the backup area of the first memory 102. In the prior art, as shown in fig. 8, after writing the data in the page buffer into the first storage unit 1031, the target data in the page buffer in the storage area needs to be released. It should be noted that, when the page buffer data is released, erasing the data in the page buffer, so that the page buffer may be written with new data. The page buffer is not able to be written with new data until the data of the page buffer is released.
Optionally, the target data is retained in a backup area of the first memory, including: and storing the target data from the storage area to the backup area, and releasing the target data in the storage area. The first memory includes a storage area for storing target data to be written into the second memory, and a backup area for storing backup data of the target data. The target data to be written into the second memory is saved from the memory area to the backup area while the target data in the original memory area is released (i.e., erased) so that the original memory area can be rewritten with new data.
Optionally, the target data is retained in a backup area of the first memory, including: the target data in the storage area is not released and the storage area is added to the backup area. The first memory includes a storage area for storing target data to be written into the second memory, and a backup area for storing backup data of the target data. After the target data in the storage area is written into the second memory, the data in the storage area is not released, but the storage area is added into the backup area, that is, the original storage area becomes the backup area, and new data cannot be rewritten. For example: as shown in fig. 7, the storage area stores a page buffer of target data, and after the target data in the page buffer is written into the first storage unit, the page buffer directly enters the backup area, i.e. becomes the page buffer in the backup area, and the target data in the page buffer is not released. In the scheme, the target data can be backed up without being referenced or copied again, so that the data loss after the second memory is reset is avoided, and meanwhile, the hardware computing resources are greatly saved.
It should be noted that, when the backup area and the storage area are distinguished, the area identifier may be used to uniquely identify whether the area is the backup area according to the area identifier. For example, for page buffers included in the backup area and the storage area, each page buffer may include an area identification for identifying whether the page buffer belongs to the backup area or the storage area. When the backup area and the storage area are distinguished, the area corresponding to the preset storage address can be used as the backup area according to the storage address. In this regard, the embodiment of the present application is not particularly limited.
It should be noted that, in addition, one specific implementation of the backup area may be a separate storage area, so as to facilitate writing of data; the other may also be a backup queue or a backup linked list, etc., and after one or more page buffers in the storage area are written to the second memory, the one or more page buffers may directly enter the backup queue or the backup linked list, so that data in the one or more page buffers is retained in the first memory.
Optionally, the not releasing the target data in the storage area and adding the storage area to the backup area includes: and adding 1 on the basis of the current reference number of the storage area, and adding the storage area into the backup area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0. For example: after the write instruction for one or more page caches is completed, the number of references in the one or more page caches is increased, so that the target data in the one or more page caches is ensured not to be released, and the target data can be rewritten into the second memory after the second memory is reset. It should be noted that, the above-mentioned current reference number of the storage area may be understood as the current reference number of the minimum unit of reading/writing (such as page buffer) of the storage area in response to the write instruction.
Optionally, before generating the write instruction, the method further includes: and increasing 1 on the basis of the current reference number of the storage area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0. Before generating the write instruction, the number of references corresponding to all storage areas available for storing the target data in the first memory may be increased by 1, so that the target data in the storage areas is written by increasing the number of references to the target data in the storage areas after the write instruction is completed, so that the data in the storage areas is ensured not to be released, and the target data can be ensured to be rewritten in the second memory after the second memory is reset. For example: the current reference times in all page caches in the storage area are increased by 1, so that data in each page cache executing the write instruction is ensured not to be released after being written into the second memory. It should be noted that, the above-mentioned current reference number of the storage area may be understood as the reference number of each minimum unit of read/write (e.g. page buffer) in the storage area.
The backup area management module 102 is configured to: and when the size of the stored data in the backup area exceeds a storage threshold value, releasing the target data stored in the backup area earliest. The storage threshold may be preset or default, or may be set according to a related management instruction of the user. When the size of the stored data of the backup area in the first memory exceeds a storage threshold (e.g., the storage size of the first memory cell), the data stored to the backup area at the earliest has been written to the second memory cell by the first memory cell, and since the second memory cell is a nonvolatile memory cell, the data is not lost even when the second memory is reset. Therefore, when the storage threshold is exceeded, the earliest reserved target data in the current backup area is released, so that the storage pressure in the first memory can be relieved, and the storage space in the first memory is ensured.
Alternatively, when the size of the data stored in the backup area exceeds a storage threshold, the backup area management module 102 may release the target storage area that entered the backup area at the earliest and the data in the target storage area. When the size of the stored data of the backup area in the first memory exceeds a storage threshold (such as the storage size of the first memory unit), the data stored in the storage area that is added to the backup area at the earliest has been written to the second memory unit by the first memory unit, and since the second memory unit is a nonvolatile memory unit, the data is not lost even when the second memory is reset. Therefore, when the storage threshold is exceeded, the storage area (i.e., new data can be rewritten) that is added to the backup area earliest in the current backup area, and the data in the storage area are released, so that the storage pressure in the first memory can be relieved, and the storage space in the first memory can be ensured.
For example: referring to fig. 9 and 10, fig. 9 is a schematic diagram of a management backup area according to an embodiment of the present application, and fig. 10 is a schematic diagram of another management backup area according to an embodiment of the present application. As shown in fig. 9, when the data size in the page caches 1-4 stored in the backup area exceeds the storage threshold, the target data stored in the page cache 1 and the page cache 1 in the backup area earliest is released, and the storage space of the original backup area is also reduced. As shown in fig. 10, when the data size in the page buffer 1-4 stored in the backup area exceeds the storage threshold, the target data stored in the page buffer 1 in the backup area at the earliest is released, and the storage space of the original backup area does not become small.
It will be appreciated that the size of the data stored in the backup area exceeding the storage threshold also corresponds to insufficient storable space in the backup area.
It is further understood that when the size of the data stored in the backup area exceeds the storage threshold, the backup area management module 102 may release the target storage area entering the backup area and the data in the target storage area according to the corresponding release policy. For example, the release policy may be to release the target storage area entered into the backup area before a preset time period from the current point in time and the data in the target storage area.
Optionally, the storage space of the backup area is greater than or equal to the storage space of the first storage unit. It should be noted that the storage space is a space where the backup area and the first storage unit can hold data. The storage space of the backup area in the first memory is not smaller than the storage space in the first storage unit, so that the lost data in the first storage unit can be completely retrieved from the data in the backup area after the first storage unit is reset, and the loss of the data is avoided. And when the storage space of the backup area is larger than or equal to the storage space of the first storage unit, the phenomenon that the data corresponding to the backup area is deleted when the data in the first storage unit is not written into the second storage unit yet can not occur.
Optionally, when receiving a notification that the storable space of the first memory is insufficient, generating an output instruction, where the output instruction is used to instruct writing all data in the first storage unit into the second storage unit; and after all the data in the first storage unit are written into the second storage unit, releasing all the storage areas in the backup area and the data in all the storage areas. When the storable space (corresponding to the storage area) of the first memory is insufficient (the memory is tensed), an output instruction can be issued to the second memory device so that all data of the first memory unit in the second memory is written into the second memory unit. After all the data are written into the second storage unit, all the storage areas in the backup area and the data in all the storage areas can be released so as to relieve the memory pressure. For example, when the storable space (equivalent to a memory area) of the first memory is insufficient (memory tension), a flush command may be issued to the second memory device, forcing the data in the first memory unit 1031 (buffer) to be flushed into the second memory unit 1032 (NAND medium), and then freeing up all data and/or page buffers in the backup area to mitigate the impact on the first memory.
The abnormal retransmission module 103 is configured to: in the case where the first storage unit 1031 in the second memory 103 is reset, part or all of the data in the backup area 1022 is rewritten to the first storage unit. That is, if an abnormality occurs in the second memory (e.g., a command cannot be responded to), after the second memory 103 is reset, some or all of the data in the backup area 1022 is retransmitted to the second memory 103. For example: referring to fig. 11, fig. 11 is a schematic diagram illustrating rewriting of target data into a second memory according to an embodiment of the present application. As shown in fig. 11, when the first storage unit 1031 loses all data at the second memory reset, the abnormal retransmission module 103 retransmits part or all of the data (one or more of the page caches 1-4) in the backup area to the first storage unit 1031 so that the data of the backup area is rewritten to the second memory.
It is understood that the structure of the processing unit 101 or the second memory 103 in fig. 4 is only some exemplary implementations provided in the embodiments of the present application, and the structure of the processing unit 101 or the second memory 103 in the embodiments of the present application includes, but is not limited to, the above implementation.
Based on the system architecture provided in fig. 3 and the structure of the data storage device provided in fig. 4, the technical problems presented in the present application are specifically analyzed and solved in combination with the data storage method provided in the present application.
Referring to fig. 12, fig. 12 is a flowchart of a data storage method according to an embodiment of the present application, where the method may be applied to the system architecture described in fig. 1, and the data storage device may be used to support and execute the method steps S201 to S205 shown in fig. 12. The following will describe from the processing unit side of the host 100 with reference to fig. 12. The method may include the following step S201-step S205.
Step S201: a write instruction is generated.
Specifically, the data storage device generates a write instruction for instructing to write target data in the first memory into the second memory. In the electronic equipment, such as a file system, when the processing device needs to store the data in the first memory into the second memory in the operation process, a write instruction can be generated to instruct to write the target data in the first memory into the second memory.
Step S202: after writing the target data to the first storage unit based on the write instruction, the target data is retained in the backup area of the first memory.
Specifically, the data storage device writes the target data to the first storage unit based on the write instruction, and then retains the target data in the backup area of the first memory. The first storage unit is a volatile storage unit in the second memory, and in order to prevent the data in the first storage unit from being lost after the second memory is reset, the target data can be stored in the backup area of the first memory after being written into the first storage unit.
Optionally, the first memory includes a storage area and the backup area, and the storage area is used for storing the target data; the retaining the target data in the backup area of the first memory includes: and storing the target data from the storage area to the backup area, and releasing the target data in the storage area. There are two schemes for the data storage device to retain the target data in the backup area of the first memory, one of which is to store the target data written in the second memory from the storage area to the backup area while freeing (i.e., erasing) the target data in the original storage area so that the original storage area can be rewritten with new data. That is, the data of one area A in the original first memory is transferred (for example, by writing, copying, etc.) to another area B, and after the transfer, the data of the original area A is deleted. In this embodiment, the size of the data that can be stored in the storage space corresponding to the storage area and the storage space corresponding to the backup area in the first memory is not changed at most. For example: the storage space corresponding to the storage area and the storage space corresponding to the backup area store data with the size of 100M at most.
Optionally, the first memory includes a storage area and the backup area, and the storage area is used for storing the target data; the retaining the target data in the backup area of the first memory includes: the target data in the storage area is not released and the storage area is added to the backup area. There are two schemes for the data storage device to keep the target data in the backup area of the first memory, wherein another way is to add the storage area to the backup area, and the data in the storage area is not released, that is, the original storage area is changed to the backup area, and the original storage area cannot be rewritten with new data. In addition, the manner in which the storage area becomes the backup area is not limited in the present application. For example: the area identification of the storage area can be changed from the storage area to a backup area, and the area identification is used for uniquely identifying whether the area is the backup area or not; the storage space corresponding to the storage area can be divided into the storage space corresponding to the backup area again, so that the storage space of the storage area is reduced, and the storage space of the backup area is increased.
Optionally, the not releasing the target data in the storage area and adding the storage area to the backup area includes: and adding 1 on the basis of the current reference number of the storage area, and adding the storage area into the backup area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0. The data storage device ensures that the data in the storage area is not released by increasing the reference times of the target data in the storage area after the write instruction is completed, and can ensure that the target data is kept in the backup area of the first memory. The number of references is used to indicate the number of times the target data in the storage area is referenced by an associated instruction (e.g., a write instruction).
Optionally, before generating the write instruction, the method further includes: and increasing 1 on the basis of the current reference number of the storage area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0. If the reference number of the storage area is not increased after the writing instruction is completed, the data storage device can increase the reference number corresponding to all the storage areas available for storing the target data in the first memory by 1 before the writing instruction is generated, so that the target data in the storage area is written by increasing the reference number of the target data in the storage area after the writing instruction is completed, the data in the storage area is ensured not to be released, and the target data can be ensured to be rewritten in the second memory after the second memory is reset.
Optionally, the storage space of the backup area is greater than or equal to the storage space of the first storage unit. The storage space of the backup area in the first memory is not smaller than the storage space in the first storage unit, so that the lost data in the first storage unit can be completely retrieved from the data in the backup area after the first storage unit is reset, and the loss of the data is avoided.
Optionally, when the size of the stored data in the backup area exceeds a storage threshold, releasing the target data stored earliest in the backup area. The storage threshold may be set in advance or by default, or when the size of the stored data of the backup area in the first memory set according to the related management instruction of the user exceeds the storage threshold (such as the storage size of the first storage unit), the data stored in the backup area at the earliest has been written into the second storage unit by the first storage unit, and since the second storage unit is a nonvolatile storage unit, the data will not be lost even when the second memory is reset. Therefore, when the storage threshold is exceeded, the earliest reserved target data in the current backup area is released, so that the storage pressure in the first memory can be relieved, and the storage space in the first memory is ensured.
Optionally, when the size of the stored data in the backup area exceeds a storage threshold, releasing the target storage area which is earliest entered into the backup area and the data in the target storage area. When the size of the stored data of the backup area in the first memory exceeds a storage threshold (such as the storage size of the first memory unit), the data stored in the storage area that is added to the backup area at the earliest has been written to the second memory unit by the first memory unit, and since the second memory unit is a nonvolatile memory unit, the data is not lost even when the second memory is reset. Therefore, when the storage threshold is exceeded, the storage area (i.e., new data can be rewritten) that is added to the backup area earliest in the current backup area, and the data in the storage area are released, so that the storage pressure in the first memory can be relieved, and the storage space in the first memory can be ensured.
Step S203: and when the first storage unit in the second memory is reset, part or all of the data in the backup area is rewritten to the first storage unit.
Specifically, when the first storage unit in the second memory is reset, the data storage device rewrites part or all of the data in the backup area to the first storage unit. Wherein, when the first storage unit is acquired which one is lost, the lost part of the data can be sent, and when the first storage unit is not determined which one is lost, part or all of the data in the backup area can be sent to avoid the data loss.
Optionally, the data storage device writes the data written in the first storage unit into the second storage unit. The first storage unit in the second memory is a volatile storage unit, and the second storage unit is a nonvolatile storage unit, and in order to save data, the data in the first storage unit needs to be written into the second storage unit.
Step S204: upon receiving a notification of insufficient storable space of the first memory, an output instruction is generated.
Specifically, the data storage device generates an output instruction when receiving the notification that the storable space of the first memory is insufficient, where the output instruction is used to instruct writing of all data in the first storage unit into the second storage unit, and the output instruction may be a flush command issued to the second storage device, for example.
Step S205: and after all the data in the first storage unit are written into the second storage unit, releasing all the storage areas in the backup area and the data in all the storage areas.
Specifically, the data storage device releases all the storage areas in the backup area and the data in all the storage areas after all the data in the first storage unit is written into the second storage unit. In order to relieve the storage pressure in the electronic device, after the data is all saved in the nonvolatile storage unit, all the storage areas in the backup area and the data in all the storage areas may be released.
Optionally, the data storage device releases all the storage areas in the backup area and the data in all the storage areas after all the data in the first storage unit is written into the second storage unit.
When the data is stored, after the data is written into the second memory, the data which needs to be erased originally is stored in the backup area of the first memory. In the case where the second memory is reset (at this time, the volatile memory unit, that is, the data in the first memory unit is lost during the reset), part or all of the data in the backup area is sent to the second memory again (the data is rewritten to the first memory unit), so that the data in the first memory unit is prevented from being lost after the second memory is reset. Moreover, the data of the resending backup area can keep the consistency of the metadata after abnormal recovery, and the loss of the actual file data of the user is avoided. In addition, the method does not need to restart the electronic equipment, so that the user experience is greatly improved.
It should be noted that, for the description of step S201 to step S205 in the data storage method described in the embodiment of the present application, reference may be made to the description of each functional unit in the embodiment of the apparatus described in fig. 4, which is not repeated here.
The foregoing details the method of the embodiments of the present application, and the following provides relevant devices of the embodiments of the present application.
Referring to fig. 13, fig. 13 is a schematic structural diagram of a data storage meter device according to an embodiment of the present application, where the data storage device 10 is applied to an electronic apparatus, and the electronic apparatus includes a first memory and a second memory, where the second memory includes a first storage unit and a second storage unit, the first memory is a volatile memory, the first storage unit is a volatile memory, and the second storage unit is a nonvolatile memory; the data storage device 10 may include a generation unit 301, a backup unit 302, a first writing unit 303, and a second writing unit 304; may further include: a reference management unit 305, a first release unit 306, a second release unit 307, an output unit 308, and a third release unit 309. Among them, the detailed description of each unit is as follows.
A generating unit 301, configured to generate a write instruction, where the write instruction is used to instruct to write target data in the first memory into the second memory;
a backup unit 302, configured to store the target data in a backup area of the first memory after writing the target data to the first storage unit based on the write instruction;
A first writing unit 303, configured to, when the first storage unit in the second memory is reset, rewrite part or all of the data in the backup area to the first storage unit;
and a second writing unit 304, configured to write the data written into the first storage unit into the second storage unit.
In one possible implementation, the first memory includes a storage area and the backup area, and the storage area is used for storing the target data; the backup unit 302 is specifically configured to: and storing the target data from the storage area to the backup area, and releasing the target data in the storage area.
In one possible implementation, the first memory includes a storage area and the backup area, and the storage area is used for storing the target data; the backup unit 302 is specifically configured to: the target data in the storage area is not released and the storage area is added to the backup area.
In one possible implementation manner, the backup unit 302 is specifically configured to: and adding 1 on the basis of the current reference number of the storage area, and adding the storage area into the backup area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0.
In one possible implementation, the apparatus further includes: a reference management unit 305, configured to increase, before generating the write instruction, 1 on the basis of the current reference number of the storage area, where the reference count is used to indicate the number of times the target data in the storage area is referenced, and when the reference number of times of the storage area is 0, release the target data in the storage area.
In one possible implementation, the storage space of the backup area is greater than or equal to the storage space of the first storage unit.
In one possible implementation, the apparatus further includes: a first releasing unit 306, configured to release the target data stored in the backup area earliest when the size of the data stored in the backup area exceeds a storage threshold.
In one possible implementation, the apparatus further includes: and a second releasing unit 307, configured to release, when the size of the data stored in the backup area exceeds a storage threshold, the target storage area that is the earliest entry into the backup area and the data in the target storage area.
In one possible implementation, the apparatus further includes: an output unit 308, configured to generate an output instruction when receiving a notification that the storable space of the first memory is insufficient, where the output instruction is used to instruct writing of all data in the first memory unit into the second memory unit; and a third releasing unit 309, configured to release all the storage areas in the backup area and the data in all the storage areas after all the data in the first storage unit is written into the second storage unit.
The division of the plurality of units is merely a logical division according to functions, and is not limited to a specific configuration of the data storage device 10. In a specific implementation, where some of the functional modules may be subdivided into more tiny functional modules, some of the functional modules may be combined into one functional module, but whether the functional modules are subdivided or combined, the general flow performed by the apparatus 10 in the process of data storage is the same. Typically, each unit corresponds to a respective program code (or program instruction), and the respective program code of these units when run on the associated hardware device causes the unit to execute a respective flow to achieve the respective function. In addition, the functions of each unit may also be implemented by associated hardware.
It should be further noted that, the functions of each functional unit in the data storage device 10 described in the embodiment of the present application may be referred to step S201 to step S205 in the method embodiment described in fig. 12 and the related descriptions of each module in the device embodiment described in fig. 4 are not repeated herein.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to related descriptions of other embodiments.
It should be noted that, for simplicity of description, the foregoing method embodiments are all expressed as a series of action combinations, but it should be understood by those skilled in the art that the present application is not limited by the order of actions described, as some steps may be performed in other order or simultaneously in accordance with the present application. Further, those skilled in the art will also appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily required in the present application.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, such as the above-described division of units, merely a division of logic functions, and there may be additional manners of dividing in actual implementation, such as multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, or may be in electrical or other forms.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units described above, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be essentially or a part contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server or a network device, etc., specifically may be a processor in the computer device) to perform all or part of the steps of the above-mentioned method of the embodiments of the present application. Wherein the aforementioned storage medium may comprise: various media capable of storing program codes, such as a U disk, a removable hard disk, a magnetic disk, a compact disk, a Read-Only Memory (abbreviated as ROM), or a random access Memory (Random Access Memory, abbreviated as RAM), are provided.
The above embodiments are merely for illustrating the technical solution of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the corresponding technical solutions.

Claims (22)

  1. The data storage method is characterized by being applied to electronic equipment, wherein the electronic equipment comprises a first memory and a second memory, the second memory comprises a first storage unit and a second storage unit, the first memory is a volatile memory, the first storage unit is a volatile storage unit, and the second storage unit is a nonvolatile storage unit; the method comprises the following steps:
    generating a write instruction, wherein the write instruction is used for indicating to write target data in the first memory into the second memory;
    after the target data is written into the first storage unit based on the writing instruction, the target data is reserved in a backup area of the first memory;
    When the first storage unit in the second memory is reset, rewriting part or all of the data in the backup area to the first storage unit;
    and writing the data written into the first storage unit into the second storage unit.
  2. The method of claim 1, wherein the first memory comprises a storage area and the backup area, the storage area for storing the target data; the retaining the target data in the backup area of the first memory includes:
    and storing the target data from the storage area to the backup area, and releasing the target data in the storage area.
  3. The method of claim 1, wherein the first memory comprises a storage area and the backup area, the storage area for storing the target data; the retaining the target data in the backup area of the first memory includes:
    the target data in the storage area is not released and the storage area is added to the backup area.
  4. The method of claim 3, wherein the not freeing the target data in the storage area and adding the storage area to the backup area comprises:
    And adding 1 on the basis of the current reference number of the storage area, and adding the storage area into the backup area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0.
  5. A method according to claim 3, wherein prior to generating the write instruction, the method further comprises:
    and increasing 1 on the basis of the current reference number of the storage area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0.
  6. The method of any of claims 1-5, wherein the storage space of the backup area is greater than or equal to the storage space of the first storage unit.
  7. The method according to claim 2, wherein the method further comprises:
    and when the size of the stored data in the backup area exceeds a storage threshold value, releasing the target data stored in the backup area earliest.
  8. A method according to claim 3, wherein the method further comprises:
    and when the size of the stored data in the backup area exceeds a storage threshold value, releasing the target storage area which is earliest entering the backup area and the data in the target storage area.
  9. The method according to claim 1, wherein the method further comprises:
    and generating an output instruction when receiving the notification of insufficient storable space of the first memory, wherein the output instruction is used for indicating that all data in the first memory unit are written into the second memory unit.
  10. The data storage device is characterized by being applied to electronic equipment, wherein the electronic equipment comprises a first memory and a second memory, the second memory comprises a first storage unit and a second storage unit, the first memory is a volatile memory, the first storage unit is a volatile storage unit, and the second storage unit is a nonvolatile storage unit; the device comprises:
    a generating unit configured to generate a write instruction for instructing writing of target data in the first memory into the second memory;
    The backup unit is used for keeping the target data in a backup area of the first memory after the target data is written into the first storage unit based on the writing instruction;
    a first writing unit, configured to, when the first storage unit in the second memory is reset, rewrite part or all of the data in the backup area to the first storage unit;
    and the second writing unit is used for writing the data written into the first storage unit into the second storage unit.
  11. The apparatus of claim 10, wherein the first memory comprises a storage area and the backup area, the storage area to store the target data; the backup unit is specifically configured to:
    and storing the target data from the storage area to the backup area, and releasing the target data in the storage area.
  12. The apparatus of claim 10, wherein the first memory comprises a storage area and the backup area, the storage area to store the target data; the backup unit is specifically configured to:
    the target data in the storage area is not released and the storage area is added to the backup area.
  13. The apparatus according to claim 12, wherein the backup unit is specifically configured to:
    and adding 1 on the basis of the current reference number of the storage area, and adding the storage area into the backup area, wherein the reference count is used for indicating the reference number of the target data in the storage area, and the target data in the storage area is released when the reference number of the storage area is 0.
  14. The apparatus of claim 12, wherein the apparatus further comprises:
    and a reference management unit configured to increase 1 on the basis of the current reference number of the storage area before the write instruction is generated, where the reference count is used to indicate the number of times the target data in the storage area is referenced, and when the reference number of times of the storage area is 0, the target data in the storage area is released.
  15. The apparatus of any of claims 10-14, wherein the storage space of the backup area is greater than or equal to the storage space of the first storage unit.
  16. The apparatus of claim 11, wherein the apparatus further comprises:
    And the first releasing unit is used for releasing the target data stored in the backup area earliest when the size of the stored data in the backup area exceeds a storage threshold value.
  17. The apparatus of claim 12, wherein the apparatus further comprises:
    and the second releasing unit is used for releasing the target storage area which is earliest to enter the backup area and the data in the target storage area when the size of the stored data in the backup area exceeds a storage threshold value.
  18. The apparatus of claim 10, wherein the apparatus further comprises:
    the output unit is used for generating an output instruction when receiving the notification of insufficient storage space of the first memory, wherein the output instruction is used for indicating that all data in the first storage unit are written into the second storage unit;
    and the third releasing unit is used for releasing all the storage areas in the backup area and the data in all the storage areas after all the data in the first storage unit are written into the second storage unit.
  19. The data storage device is characterized by being applied to electronic equipment, wherein the electronic equipment comprises a first memory and a second memory, the second memory comprises a first storage unit and a second storage unit, the first memory is a volatile memory, the first storage unit is a volatile storage unit, and the second storage unit is a nonvolatile storage unit; the apparatus comprising a processor configured to perform the method of any of claims 1-9.
  20. An electronic device comprising a processor, a first memory, and a second memory, the processor coupled with the first memory and the second memory; the second memory comprises a first memory unit and a second memory unit, the first memory is a volatile memory, the first memory unit is a volatile memory unit, and the second memory unit is a nonvolatile memory unit; wherein the processor is configured to invoke the program code stored by the electronic device to cause the electronic device to perform any of the methods of claims 1-9.
  21. 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 method of any of the preceding claims 1-9.
  22. A computer program comprising instructions which, when executed by a computer, cause the computer to perform the method of any of claims 1-9.
CN202180099157.2A 2021-06-15 2021-06-15 Data storage method and related equipment Pending CN117501247A (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/100100 WO2022261823A1 (en) 2021-06-15 2021-06-15 Data storage method and related device

Publications (1)

Publication Number Publication Date
CN117501247A true CN117501247A (en) 2024-02-02

Family

ID=84526769

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202180099157.2A Pending CN117501247A (en) 2021-06-15 2021-06-15 Data storage method and related equipment

Country Status (2)

Country Link
CN (1) CN117501247A (en)
WO (1) WO2022261823A1 (en)

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005258851A (en) * 2004-03-12 2005-09-22 Renesas Technology Corp Memory card
CN100349127C (en) * 2004-12-03 2007-11-14 华为技术有限公司 Embedded system data back-up device and method
US7441070B2 (en) * 2006-07-06 2008-10-21 Qimonda North America Corp. Method for accessing a non-volatile memory via a volatile memory interface
CN101216789A (en) * 2008-01-08 2008-07-09 福建星网锐捷网络有限公司 Data update method, device and system
KR101562973B1 (en) * 2009-05-22 2015-10-26 삼성전자 주식회사 Memory apparatus and method for operating thereof
CN102314321B (en) * 2010-07-07 2015-11-25 深圳市朗科科技股份有限公司 Storage system, utilization storage system carry out the method and apparatus of data access

Also Published As

Publication number Publication date
WO2022261823A1 (en) 2022-12-22

Similar Documents

Publication Publication Date Title
US11768632B2 (en) Memory system and method of controlling nonvolatile memory
JP5376983B2 (en) Memory system
US8737148B2 (en) Selective retirement of blocks
US10168940B2 (en) Data storage using SLC and TLC memory banks and data maintenance method thereof
US10956323B2 (en) NVDIMM emulation using a host memory buffer
CN105718530B (en) File storage system and file storage control method thereof
US20130013853A1 (en) Command executing method, memory controller and memory storage apparatus
CN109952565B (en) Memory access techniques
CN105378682A (en) Observation of data in persistent memory
CN103838676B (en) Data-storage system, date storage method and PCM bridges
CN112130749B (en) Data storage device and non-volatile memory control method
CN115599706B (en) Garbage recycling method of data storage device and data storage device
JP6961759B2 (en) How to perform refresh management in memory devices, related memory devices and their controllers
TW202101223A (en) Data storage device and non-volatile memory control method
CN113986773A (en) Write amplification optimization method and device based on solid state disk and computer equipment
CN111459400B (en) Method and apparatus for pipeline-based access management in storage servers
US11347433B2 (en) Method for performing sudden power off recovery management, associated memory device and controller thereof, and associated electronic device
KR20170132483A (en) Method of operating memory device
CN113268437A (en) Method and equipment for actively triggering memory sorting
US20190227740A1 (en) Atomic write method for multi-transaction
CN111164694B (en) Memory device and method for volatile management of a memory device
CN113448487A (en) Computer readable storage medium, method and device for writing flash memory management table
CN117501247A (en) Data storage method and related equipment
US10817435B1 (en) Queue-based wear leveling of memory components
CN109002265B (en) Data processing method and related device

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