CN113590501A - Data storage method and related equipment - Google Patents

Data storage method and related equipment Download PDF

Info

Publication number
CN113590501A
CN113590501A CN202010371512.4A CN202010371512A CN113590501A CN 113590501 A CN113590501 A CN 113590501A CN 202010371512 A CN202010371512 A CN 202010371512A CN 113590501 A CN113590501 A CN 113590501A
Authority
CN
China
Prior art keywords
data
type
storage area
storage
target data
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
CN202010371512.4A
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
Priority to CN202010371512.4A priority Critical patent/CN113590501A/en
Publication of CN113590501A publication Critical patent/CN113590501A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/72Details relating to flash memory management
    • G06F2212/7201Logical to physical mapping or translation of blocks or pages

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The embodiment of the invention discloses a data storage method and related equipment, which are applied to storage equipment, wherein the storage equipment is a nonvolatile memory and at least comprises a first storage area and a second storage area, and the method comprises the following steps: receiving a write command for target data, wherein the write command comprises a data type identification of the target data; writing the target data and the data type identification into the first storage area according to the write command; if the storage space occupied by the target data needs to be recovered, identifying the data type of the target data according to the data type identifier; if the target data is determined to be the first type, the target data is reserved in the first storage area; and if the target data is determined to be of the second type, moving the target data to the second storage area. By adopting the embodiment of the invention, the read-write performance of the data can be improved.

Description

Data storage method and related equipment
Technical Field
The present invention relates to the field of storage technologies, and in particular, to a data storage method and related device.
Background
With the continuous development of storage technology, Flash memories using Flash memories (NAND Flash) as storage media are becoming mainstream storage forms. NAND Flash is a non-volatile random access storage medium that is characterized by data that does not disappear after power is turned off. Currently, NAND Flash mainly includes the following types according to the storage principle: Single-Level Cell (SLC), Multi-Level Cell (MLC), Triple-Level Cell (TLC), and the like. Wherein,
(1) SLC has only two charge values of 0 and 1, i.e. 1 memory cell can store 1bit data (1bit per cell), about 10 ten thousand erasing life. The design of the SLC improves the durability, accuracy and storage performance, and is characterized by high cost, small capacity and fast read-write speed.
(2) The MLC has four charge values of 00, 01, 10 and 11, i.e. 1 memory cell can store 2bit data (2bit per cell), which is about 1 ten thousand times erasing life. The MLC has a capacity twice as large as SLC, but it has the cost of reduced service life and reliability, and generally it features ordinary cost, capacity and much slower read-write speed than SLC.
(3) TLC has eight charge values of 000, 001, 010, 011, 100, 101, 110 and 111, i.e. 1 storage cell can store 3 bits of data (3bit per cell), about 5000 times of erase life. TLC has twice more capacity than SLC, but it also has the cost of lower lifetime and lower reliability, and generally it is characterized by low cost, large capacity, much slower read/write speed than both SLC and MLC, and is generally used in consumer electronics with relatively low performance and durability requirements.
Based on the characteristics of the SLC that the storage speed is fast but the cost is high, and the MLC/TLC that the cost is low but the storage speed is slow, in the prior art, especially in the application of the mobile terminal, an SLC buffering (slcb buffer) technology is introduced. The SLC Buffer technology is that a high-performance SLC writing Buffer area is added in a flash memory, and when data needs to be written, a Host (Host) side firstly writes the data into the SLC Buffer area in the flash memory; when the flash memory is free, the data is moved from the SLC buffer to the TLC area where the data is actually stored. The core content of the technology is to introduce the combination of SLC and TLC, and the performance of the TLC-based flash memory is improved by utilizing the characteristic of SLC fast reading and writing, so that a user can experience the highest speed in the initial stage of writing.
However, in an actual user usage scenario, the flash memory may read data in addition to write data, and in the above-mentioned flash memory applying the slcb buffer technology, when data is read from the TLC storage area, the defect of slow reading speed still may be exposed, thereby affecting the overall performance and user experience of the flash memory. Therefore, how to provide a flash memory with low cost and better read-write performance is an urgent problem to be solved.
Disclosure of Invention
The embodiment of the invention provides a data storage method and related equipment, which are used for improving the read-write performance of stored data.
In a first aspect, an embodiment of the present invention provides a data storage method, which is applied to a storage device, where the storage device is a nonvolatile memory and includes at least a first storage area and a second storage area, and a storage performance of the first storage area is better than that of the second storage area; the method may comprise: receiving a write command for target data, wherein the write command comprises a data type identification of the target data; writing the target data and the data type identification into the first storage area according to the write command; if the storage space occupied by the target data needs to be recovered, identifying the data type of the target data according to the data type identifier; the data types comprise a first type and a second data type; if the target data is determined to be the first type, the target data is reserved in the first storage area; if the target data is determined to be of the second type, moving the target data to the second storage area; wherein the first type of data has a higher storage performance requirement than the second type of data.
According to the embodiment of the invention, when data is written into a storage device (such as a flash memory of a mobile phone), all types of data are uniformly written into a first storage area with better storage performance (such as random reading/writing performance) so as to improve the writing performance of initial storage of target data; because the data type identifier of the data is carried in the write command of the data, and the corresponding data type identifier is stored while the target data is written, when the target data is subsequently retrieved with respect to the storage space (for example, the physical block in which the target data is located) occupied by the target data, whether the target data continuously resides in the first storage area with better storage performance or is retrieved to the second storage area with relatively poorer storage performance can be determined according to the data type identifier. When the host side needs to read the target data next time, the target data can be directly read from the storage area where the target data is located, so that the requirements of different types of data on different storage performances are met, and particularly, the reading speed of the first type of data is improved. For example, when the storage space for the target data is recycled, when the target data is a first type of data with higher demand on random reading performance, the target data continues to reside in the first storage area; when the target data is a second type of data with a slightly lower requirement on the random reading performance, the target data can be recycled to the second storage area; subsequently, when the host side reads out the target data of the first type from the first storage area, the read speed of the data of the first type can be increased based on the better storage performance provided by the first storage area, so as to meet the higher requirement of the host side on the random read performance. In conclusion, the embodiment of the invention can greatly improve the read/write comprehensive performance of data.
In one possible implementation, the method further includes: receiving a read command for the target data; if the target data is of the first type, controlling the target data to be read out from the first storage area; and if the target data is of the second type, controlling the target data to be read out from the second storage area.
In the embodiment of the present invention, after the storage space of the target data is recovered, and the target data respectively resides in the first storage area or is recovered to the second storage area, if the host side needs to read the target data from the storage device, if the target data currently resides in the first storage area as the first type of data, the host side directly reads the target data from the first storage area at this time; if the target data is currently stored in the second storage area as the second type of data, the host side directly reads the target data from the second storage area at this time. When the target data is the first type of data with higher requirement on storage performance, the target data can be directly read from the first storage area with better storage performance so as to improve the reading performance of the first type of data.
In a possible implementation manner, if it is determined that the target data is of the first type, the retaining the target data in the first storage area includes: and if the target data is determined to be the first type, keeping the target data and the data type identification in the first storage area.
In the embodiment of the invention, after the target data is determined to be the first type, the target data and the corresponding data type identification are resident in the first storage area together, and are not moved to the second storage area. That is, the data type identifier is used as one of the attributes of the target data, and long-term storage and circulation are performed in the subsequent data read/write process, so that when the target data is subsequently transferred or stored, the stored area can still be determined according to the stored data type identifier.
In a possible implementation manner, the storage device is one or more of a universal flash memory UFS, an embedded multimedia card eMMC, a universal flash memory multi-chip package upmcp memory, and an embedded multimedia card multi-chip package eMCP memory; the first storage area comprises one or more of a single-layer cell SLC storage area, a Fast NAND memory, a Phase Change Memory (PCM) and a 3D stacked phase change memory (X3D), and the second storage area comprises one or more of a multi-layer cell (MLC) storage area, a three-layer cell (TLC) storage area, a four-layer cell (QLC) storage area and a five-layer cell (PLC) storage area.
In the embodiment of the present invention, the storage device may be various flash memories or flash memory chips used in the mobile terminal, such as a mobile phone flash memory or a mobile phone flash memory chip. Wherein the storage device may include one or more of UFS, eMMC, eMCP, upmc. Specifically, the first storage area may include one or more of SLC, Fast NAND, PCM, X3D, and the second storage area may include one or more of MLC, TLC, QLC, PLC.
In one possible implementation manner, the writing the target data and the data type identifier into the first storage area includes: writing the target data and the data type identifier into a first storage Block in the first storage area; if the target data is determined to be the first type, the step of retaining the target data in the first storage area includes: and if the target data is determined to be the first type, moving the target data and the data type identifier from a first Block in the first storage area to a second Block in the first storage area.
According to the embodiment of the invention, when the storage space occupied by the target data is recovered, the target data may need to be rewritten into other physical blocks in the first storage area according to the characteristics of some storage media, so that the storage space occupied by the target data is vacated. For example, in the SLC, when the storage space occupied by the target data is recovered in units of physical blocks (that is, the erase is in units of blocks), the storage space occupied by the target data is actually recovered as a whole for the physical block where the target data is located, and therefore, it is necessary to move all valid data in the physical block where the target data is located, specifically, the storage space of the whole physical block is recovered by moving the target data of the first type to another physical block in the first storage area and moving the target data of the second type to the second storage area.
In one possible implementation, the first memory region comprises an SLC memory region; the SLC storage area comprises a static SLC storage area and a dynamic SLC storage area; the first Block is a Block in the static SLC storage area, and the second Block is a Block in the dynamic SLC storage area; or the first Block is a Block in the dynamic SLC memory region, and the second Block is a Block in the static SLC memory region, or both the first Block and the second Block are blocks in the static SLC memory region; or both the first Block and the second Block are blocks in the extended dynamic SLC memory region.
In the embodiment of the present invention, when the first storage region is an SLC storage region and includes a static SLC storage region and a dynamic SLC storage region, the target data (whether of the first type or the second type) may be initially stored in the static SLC storage region or the dynamic SLC storage region. That is, in the embodiment of the present invention, it is not specifically limited whether the target data is initially stored in the dynamic SLC area or the static SLC area, and when the target data is subsequently moved, it is not specifically limited whether the target data is moved between the blocks in the static SLC storage area or the blocks in the dynamic SLC storage area or the blocks in the static SLC storage area, as long as the first type of data is moved between the blocks in the SLC storage area.
In a possible implementation manner, the moving the target data to the second storage area if it is determined that the target data is of the second type includes: and if the target data type is determined to be a second type, rewriting the target data and the data type identifier into the second storage area, and setting the target data in the first storage area as invalid. Optionally, the data type identifier of the second type of target data may be deleted at this time.
In the embodiment of the present invention, when the target data is the second type of data, and when the storage space occupied by the target data is recovered, because the storage performance requirement of the type of data is low, more space in the first storage area can be reserved for the first type of data with higher storage performance requirement by recovering the type of data into the second storage area. The specific way of recovering the target data and the corresponding data type identifier into the second storage area is to rewrite the target data and the corresponding data type identifier into the second storage area, and to set the original target data in the first storage area as invalid, so that the second type of data is moved.
In one possible implementation, the storage performance includes one or more of a random read performance, a random write performance, and a storage lifetime.
In the embodiment of the invention, the random reading performance, the random writing performance or the storage life of the first storage area and the like are superior to those of the second storage area, and correspondingly, the demand of the first type of data on the random reading performance, the random writing performance or the storage time is higher than that of the second type of data. That is, the data with different performance requirements are respectively stored in the storage areas meeting the different performance requirements, thereby improving the overall performance of data storage.
In one possible implementation, the first type of data includes one or more of file system metadata, a high frequency access database, SWAP area SWAP data.
In the embodiment of the present invention, the first type of data may be index data in a file system, or a database accessed by a user at a high frequency, or SWAP data that is temporarily replaced in a memory space and then possibly restored at any time in the subsequent process, and the data is set as the first type of data, so that the operating efficiency and performance of the storage system or a host system where the storage system is located may be further improved.
In a second aspect, an embodiment of the present invention provides a data storage method, which is applied to a host, where the method may include:
determining the data type of target data to be written into the storage equipment; the data type comprises a first type or a second type;
generating a write command for the target data, the write command including a data type identification of the target data; the data type identification is used for identifying the first type or the second type;
and sending the write command to the storage device, wherein the write command is used for indicating the storage device to store the target data and the data type identifier.
In one possible implementation, the method further includes:
judging whether the target data is any one of file system metadata, a high-frequency access database or SWAP data of an exchange area;
if yes, determining the target data as the first type of data;
if not, the target data is judged to be the second type of data, and the storage performance requirement of the first type of data is higher than that of the second type of data.
In one possible implementation, the method further includes:
sending a read command for the target data to the storage device;
if the target data is the first type, reading the target data and the data type identifier from the first storage area;
and if the target data is of the second type, reading the target data and the data type identifier from the second storage area.
In a possible implementation manner, the host further includes an internal memory, and the internal memory is a volatile memory;
the method further comprises the following steps: and storing the read target data and the data type identification into the internal memory.
In a third aspect, an embodiment of the present invention provides a storage device, which is a nonvolatile memory, and may include: the solid-state storage system comprises a storage controller and a solid-state storage array coupled with the storage controller, wherein the solid-state storage array at least comprises a first storage area and a second storage area, and the storage performance of the first storage area is better than that of the second storage area; wherein,
the storage controller is configured to:
receiving a write command for target data, wherein the write command comprises a data type identification of the target data;
writing the target data and the data type identification into the first storage area according to the write command;
if the storage space occupied by the target data needs to be recovered, identifying the data type of the target data according to the data type identifier;
if the target data is determined to be the first type, the target data is reserved in the first storage area; if the target data is determined to be of the second type, moving the target data to the second storage area; wherein the first type of data has a higher storage performance requirement than the second type of data.
In one possible implementation, the storage controller is further configured to:
receiving a read command for the target data;
if the target data is of the first type, controlling the target data to be read out from the first storage area;
and if the target data is of the second type, controlling the target data to be read out from the second storage area.
In one possible implementation, the storage controller is specifically configured to:
and if the target data is determined to be the first type, keeping the target data and the data type identification in the first storage area.
In a possible implementation manner, the storage device is one or more of a universal flash memory UFS, an embedded multimedia card eMMC, a universal flash memory multi-chip package upmcp memory, and an embedded multimedia card multi-chip package eMCP memory; the first storage area comprises one or more of a single-layer cell SLC storage area, a Fast NAND memory, a Phase Change Memory (PCM) and a 3D stacked phase change memory (X3D), and the second storage area comprises one or more of a multi-layer cell (MLC) storage area, a three-layer cell (TLC) storage area, a four-layer cell (QLC) storage area and a five-layer cell (PLC) storage area.
In one possible implementation, the storage controller is specifically configured to:
writing the target data and the data type identifier into a first storage Block in the first storage area;
and if the target data is determined to be the first type, moving the target data and the data type identifier from a first Block in the first storage area to a second Block in the first storage area.
In one possible implementation, the first memory region comprises an SLC memory region; the SLC storage area comprises a static SLC storage area and a dynamic SLC storage area;
the first Block is a Block in the static SLC storage area, and the second Block is a Block in the dynamic SLC storage area; or,
the first Block is a Block in the dynamic SLC memory region, the second Block is a Block in the static SLC memory region, or,
the first Block and the second Block are both blocks in the static SLC storage area; or,
the first Block and the second Block are both blocks in the extended dynamic SLC memory region.
In one possible implementation, the storage controller is specifically configured to:
and if the target data type is determined to be a second type, rewriting the target data and the data type identifier into the second storage area, and setting the target data in the first storage area as invalid.
In one possible implementation, the storage performance includes one or more of a random read performance, a random write performance, and a storage lifetime.
In one possible implementation, the first type of data includes one or more of file system metadata, a high frequency access database, SWAP area SWAP data.
In a fourth aspect, an embodiment of the present invention provides a host, which may include: a host controller, wherein,
the host controller is configured to:
determining the data type of target data to be written into the storage equipment; the data type comprises a first type or a second type;
generating a write command for the target data, the write command including a data type identification of the target data; the data type identification is used for identifying the first type or the second type;
and sending the write command to the storage device, wherein the write command is used for indicating the storage device to store the target data and the data type identifier.
In one possible implementation, the host controller is further configured to:
judging whether the target data is any one of file system metadata, a high-frequency access database or SWAP data of an exchange area;
if yes, determining the target data as the first type of data;
if not, the target data is judged to be the second type of data, and the storage performance requirement of the first type of data is higher than that of the second type of data.
In one possible implementation, the host controller is further configured to:
sending a read command for the target data to the storage device;
if the target data is the first type, reading the target data and the data type identifier from the first storage area;
and if the target data is of the second type, reading the target data and the data type identifier from the second storage area.
In a possible implementation manner, the host further includes an internal memory, and the internal memory is a volatile memory;
the host controller is further configured to: and storing the read target data and the data type identification into the internal memory.
In a fifth aspect, an embodiment of the present invention provides an electronic device, which may include: a host and a storage device coupled to the host;
the host is the host according to any implementation manner of the fourth aspect;
the storage device is the storage device according to any implementation manner of the third aspect.
In a sixth aspect, an embodiment of the present invention provides a data storage method applied to an electronic device, where the electronic device includes an internal memory and an external memory, the internal memory includes a normal partition and a SWAP partition, the external memory includes a first storage area and a second storage area, and storage performance of the first storage area is better than that of the second storage area, and the method may include: the electronic equipment runs N application programs, and running data of the N application programs is stored in the internal memory; the N application programs comprise first application programs, the first application programs are application programs operated in a foreground, the first application programs occupy partial space of the common partition, and N is a positive integer; in response to a start operation of a second application, the electronic device determining a remaining space of the normal partition and a remaining space of the SWAP partition; if the remaining space of the ordinary partition and the remaining space of the SWAP partition are insufficient, determining the data of the SWAP partition as data of a first type, storing the data into the first storage area, and emptying the SWAP partition; compressing the running data of M application programs in the N application programs, storing the compressed running data to the SWAP partition, and releasing the common partition occupied by the M application programs; wherein the M applications comprise the first application; foreground running the second application; the second application program occupies part or all of the common partitions occupied by the released M application programs; responding to the starting operation of the first application program, and reading the running data of the first application program from the SWAP partition; decompressing the running data of the first application program, and running the first application program in a foreground.
In the embodiment of the present invention, when the memory space of the electronic device is insufficient, including that the space of the SWAP partition in the memory is insufficient, the data of the SWAP partition may be determined as the first type of data in the embodiment of the present invention, and the first type of data is stored in the first storage area in the external memory instead, so that the space of the SWAP partition in the internal memory may be released, and therefore, part of the data of the normal partition in the internal memory may be further compressed to the SWAP partition and the space of the normal partition may be released again to meet the memory space requirement of more applications. Based on the above, the application program that may need to be killed may not be killed, but may continue to remain in the first storage area with the faster storage speed, thereby achieving the effect of expanding the SWAP partition. The keep-alive rate of the background application program is improved when the memory space is insufficient, namely under the condition of the same memory space size, the electronic device provided by the embodiment of the invention can enable more application programs to keep the running data (including the context state) of the application programs, so that the purpose of not being killed is realized, and when a user needs to call out the application programs from the background again, the application programs can return to the suspended state, so that the user experience is greatly improved.
In one possible implementation manner, before the reading of the running data of the first application program from the SWAP partition, the method further includes: searching the running data of the first application program in the first storage area; and reading the running data containing the first application program in the first storage area into the SWAP partition.
In some possible cases, for example, when the second application program runs in the foreground, the user runs another application program, so that the remaining space of the normal partition and the SWAP partition is still insufficient, at this time, the process of determining the data of the SWAP partition as the data of the first type, storing the data into the first storage area, and emptying the SWAP partition needs to be performed again; that is, the compressed running data of the M applications in the N applications is transferred from the SWAP partition to the first storage area, and the SWAP partition is emptied. And because the compressed running data of the M application programs includes the running data compressed by the first application program, if the user needs to restore the first application program again, the running data compressed by the first application program is restored from the SWAP partition to the normal partition in a manner of searching the first storage area for the running data compressed by the first application program and reloading the running data into the SWAP partition, so as to facilitate normal running.
In one possible implementation, the method further includes: and selecting M application programs with high priority levels from the N application programs to determine the M application programs, and releasing the space of the common partition occupied by the L application programs with low priority levels in the N application programs.
In the embodiment of the invention, for part of the application programs with lower user use frequency or lower priority, the searching and killing can be performed when the memory space (such as the residual space of the common partition) is not enough, the space occupied by the application programs in the common partition is directly released, namely the space of the SWAP partition is not occupied by the application programs, and more space of the common partition and the SWAP partition is reserved for the application programs with higher priority or the programs with higher user use frequency. The priority of the application program may be determined by the electronic device by monitoring the use frequency of the user, or may be manually set by the user, for example, setting the application program that the user wants to keep alive to be high in priority, and setting other common application programs to be low in priority.
In a possible implementation manner, the determining the data of the SWAP partition as the first type of data, and storing the data into the first storage area includes: generating a write command for data of the SWAP partition, the write command including a data type identification of a first type of data of the SWAP partition; and storing the data of the SWAP partition and the data type identifier of the first type into the first storage area according to the write command.
In the embodiment of the present invention, after the data of the SWAP partition is determined as the first type of data, the data type identifier of the data of the SWAP partition is carried in the write command of the data of the SWAP partition, and the data of the SWAP partition is written while the corresponding data type identifier is stored, so that when a storage space (for example, a physical block where the data of the SWAP partition is located) occupied by the subsequent data of the SWAP partition is retrieved, it can be determined according to the data type identifier that the data of the SWAP partition can continuously reside in the first storage area with better storage performance, rather than being retrieved as the second type of data to the second storage area with relatively poorer storage performance.
In one possible implementation, the method further includes: if the storage space of the first storage area meets the recovery condition, the data of the first type is kept in the first storage area, and the data of the second type is recovered to the second storage area; wherein the first type of data has a higher storage performance requirement than the second type of data.
In the embodiment of the invention, the data of each type can be uniformly written into the first storage area with better storage performance (such as random reading/writing performance) so as to improve the writing performance of initial storage of various types of data; because the data type identifier of the data is carried in the write command of the data, and the data type identifier corresponding to the data is stored while the data is written, when the data is subsequently recovered with respect to the storage space (for example, the physical block in which the data is located) occupied by the data, whether the data continuously resides in the first storage area with better storage performance or is recovered to the second storage area with relatively poorer storage performance can be determined according to the data type identifier.
In one possible implementation manner, the storing the data of the SWAP partition and the data type identifier of the first type into the first storage area includes: storing the data of the SWAP partition and the data type identification of the first type into a first storage Block in the first storage area; if the storage space of the first storage area meets the recycling condition, the step of retaining the first type of data in the first storage area comprises: and if the storage space of the first storage area meets the recovery condition, moving the data of the SWAP partition and the data type identifier of the first type from a first storage Block in the first storage area to a second Block in the first storage area.
In the embodiment of the present invention, when the storage space occupied by the data of the SWAP partition in the first storage area is recovered, according to the characteristics of some storage media, the data of the SWAP partition may need to be rewritten into other physical blocks in the first storage area, so as to vacate the storage space occupied by the data of the SWAP partition. For example, in the SLC, if the recovery memory space is in physical block units (i.e., the erase is in block units), when the memory space occupied by the SWAP partition is recovered, the physical block in which the SWAP partition is located is actually recovered in its entirety, so that all valid data in the physical block in which the SWAP partition is located needs to be moved, specifically, the memory space of the entire physical block is recovered by moving the first type of SWAP partition into another physical block in the first memory area and moving the second type of other data into the second memory area.
In a seventh aspect, an embodiment of the present invention provides a data storage apparatus, which is applied to an electronic device, where the electronic device includes an internal memory and an external memory, the internal memory includes a normal partition and a SWAP partition, the external memory includes a first storage area and a second storage area, and storage performance of the first storage area is better than that of the second storage area, and the apparatus includes:
a first operation unit, configured to operate N application programs, where operation data of the N application programs is stored in the internal memory; the N application programs comprise first application programs, the first application programs are application programs operated in a foreground, the first application programs occupy partial space of the common partition, and N is a positive integer;
a first response unit, configured to, in response to a start operation of a second application program, determine a remaining space of the normal partition and a remaining space of the SWAP partition by the electronic device;
a first storage unit, configured to determine, if both the remaining space of the normal partition and the remaining space of the SWAP partition are insufficient, that data of the SWAP partition is data of a first type, store the data in the first storage area, and empty the SWAP partition; compressing the running data of M application programs in the N application programs, storing the compressed running data to the SWAP partition, and releasing the common partition occupied by the M application programs; wherein the M applications comprise the first application;
a second running unit for foreground running the second application; the second application program occupies part or all of the common partitions occupied by the released M application programs;
a second response unit, configured to read, in response to a start operation on the first application program, running data of the first application program from the SWAP partition;
and the third running unit is used for decompressing the running data of the first application program and running the first application program in a foreground.
In one possible implementation, the apparatus further includes:
a searching unit, configured to search the first storage area for the running data of the first application before reading the running data of the first application from the SWAP partition;
and reading the running data containing the first application program in the first storage area into the SWAP partition.
In one possible implementation, the apparatus further includes:
and the determining unit is used for selecting M application programs with high priority levels from the N application programs, determining the M application programs as the M application programs, and releasing the space of the common partition occupied by the L application programs with low priority levels in the N application programs.
In a possible implementation manner, the first storage unit is specifically configured to:
generating a write command for data of the SWAP partition, the write command including a data type identification of a first type of data of the SWAP partition;
and storing the data of the SWAP partition and the data type identifier of the first type into the first storage area according to the write command.
In one possible implementation, the apparatus further includes:
the second storage unit is used for keeping the data of the first type in the first storage area and recovering the data of the second type to the second storage area if the storage space of the first storage area meets the recovery condition; wherein the first type of data has a higher storage performance requirement than the second type of data.
In a possible implementation manner, the first storage unit is specifically configured to: storing the data of the SWAP partition and the data type identification of the first type into a first storage Block in the first storage area;
the second storage unit is specifically configured to: and if the storage space of the first storage area meets the recovery condition, moving the data of the SWAP partition and the data type identifier of the first type from a first storage Block in the first storage area to a second Block in the first storage area.
In an eighth aspect, the present application provides a semiconductor chip, which may include the memory device according to any one of the implementation manners of the third aspect.
In a ninth aspect, the present application provides a semiconductor chip that can include the host according to any one of the above-described implementation manners of the fourth aspect.
In a tenth aspect, the present application provides a chip system, where the chip system includes the storage device according to any implementation manner of the third aspect. The chip system may be formed by a chip, or may include a chip and other discrete devices.
In an eleventh aspect, the present application provides a chip system, which includes the host according to any one of the implementation manners of the fourth aspect. The chip system may be formed by a chip, or may include a chip and other discrete devices.
In a twelfth aspect, the present application provides a chip system, where the chip system includes the electronic device according to any implementation manner of the sixth aspect. The chip system may be formed by a chip, or may include a chip and other discrete devices.
In a thirteenth aspect, the present application provides an electronic device, including a processor and a memory, where the memory is configured to store program codes, and the processor is configured to call the program codes stored in the memory to execute the storage device according to any implementation manner of the sixth aspect.
In a fourteenth aspect, the present application provides a system on chip SoC chip, where the SoC chip includes the host according to any implementation manner of the fourth aspect, and optionally, further includes an internal memory and an external memory coupled to the host. The SoC chip may be formed of a chip, or may include a chip and other discrete devices.
In a fifteenth aspect, the present application provides a storage device having a function of implementing any one of the data storage methods in the first aspect. The function can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the functions described above.
In a sixteenth aspect, the present application provides a host having a function of implementing any one of the data storage methods in the second aspect. The function can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the functions described above.
In a seventeenth aspect, the present application provides a terminal comprising a host including the host according to any one of the implementation manners of the fourth aspect and a storage device including the storage device according to any one of the implementation manners of the third aspect. The terminal may also include a communication interface for the terminal to communicate with other devices or communication networks.
In an eighteenth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a storage device, the computer program implements the flow of the data storage method of any one of the first aspect.
In a nineteenth aspect, the present application provides a computer-readable storage medium, which stores a computer program, when the computer program is executed by a host, the computer program implementing the flow of the data storage method according to any one of the second aspects.
In a twentieth aspect, the present application provides a computer-readable storage medium storing a computer program which, when executed by an electronic device, implements the flow of the data storage method according to any one of the above-mentioned sixth aspects.
In a twenty-first aspect, an embodiment of the present invention provides a computer program, where the computer program includes instructions, and when the computer program is executed by a storage device, the storage device may execute the flow of the data storage method in any one of the above-mentioned first aspects.
In a twenty-second aspect, an embodiment of the present invention provides a computer program, where the computer program includes instructions, and when the computer program is executed by a host, the host may execute the flow of the data storage method in any one of the above-mentioned second aspects.
In a twenty-third aspect, an embodiment of the present invention provides a computer program, where the computer program includes instructions, and when the computer program is executed by an electronic device, a host may execute the flow of the data storage method in any one of the above-described sixth aspects.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments or the background art of the present invention, the drawings required to be used in the embodiments or the background art of the present invention will be described below.
Fig. 1A is a data flow architecture diagram of a dynamic and static SLC Buffer in the prior art.
Fig. 1B is a schematic diagram of an SLC Zone technology in the prior art.
Fig. 2A is a schematic structural diagram of a host and a storage device according to an embodiment of the present invention.
Fig. 2B is a schematic structural diagram of a storage device according to an embodiment of the present invention.
Fig. 2C is a user interface diagram of some adjustment cache areas and normal areas according to an embodiment of the present invention.
Fig. 2D is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Fig. 3A is a schematic interface diagram of some users performing fast mode setting according to an embodiment of the present invention.
Fig. 3B is a schematic structural diagram of another electronic device according to an embodiment of the present invention.
Fig. 4A is a schematic diagram of a write command format according to an embodiment of the present invention.
Fig. 4B is a schematic diagram of another write command format according to an embodiment of the invention.
5A-5C are diagrams of some embodiments of the present invention providing for writing new data to a static SLC storage area of a storage device.
Fig. 6A-6C are schematic diagrams of some embodiments of the present invention for writing new data to the dynamic SLC memory region of the memory device.
Fig. 7A-7C are diagrams of some embodiments of the present invention for overwriting existing data in a dynamic SLC memory region of a memory device.
Fig. 8A-8C are schematic diagrams of data recovery in some garbage recovery processes according to embodiments of the present invention.
Fig. 9A is a flowchart of a data storage method according to an embodiment of the present invention.
Fig. 9B is a schematic structural diagram of another electronic device according to an embodiment of the present invention.
Fig. 9C-9E are schematic diagrams of some user interfaces for using applications according to embodiments of the present invention.
Fig. 10 is a general flow chart of a data storage method according to an embodiment of the present invention.
Detailed Description
The embodiments of the present invention will be described below with reference to the drawings.
The terms "first," "second," "third," and "fourth," etc. in the description and claims of this application and in the accompanying drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase 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. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can 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 can reside within a process and/or thread of execution and a component can be localized on one computer and/or distributed between 2 or more computers. In addition, 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 another component 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 the present application are explained so as to be easily understood by those skilled in the art.
(1) Nand Flash (Not AND Flash, nand Flash) is a non-volatile storage medium that can still store data after power is turned off. The development aim of the method is to reduce the storage cost per bit and improve the storage capacity. Generally, NAND Flash reads and writes in units of pages (pages) and erases (erases) in units of blocks (blocks). Due to the Flash storage principle, data (bit) can only be changed from 1 to 0 by writing the data into Flash; while an erasure can only change all data (bit) from 0 to 1. Therefore, the modified data or the newly written data must be written to the erased free page, otherwise the data will be disorganized.
(2) A Solid State Drive (SSD), commonly referred to as a Solid State Disk, is a hard Disk made of an array of Solid State electronic memory chips. The SSD is composed of a control unit and a storage unit (FLASH chip, DRAM chip). The FLASH chip in the SSD usually adopts the NAND FLASH chip as its storage unit. The specification, definition, function and use method of the interface of the solid state disk are completely the same as those of a common hard disk, and the appearance and size of the product are also completely consistent with those of the common hard disk. The method is widely applied to the fields of military affairs, vehicle-mounted, industrial control, video monitoring, network terminals, electric power, medical treatment, aviation, navigation equipment and the like.
(3) SSD reserved space (OP) refers to the capacity that is not operable by a user, and is the actual capacity of the SSD minus the available capacity of the user. Simply speaking, the OP can improve wear-leveling (wear-leveling) of the SSD, reduce write amplification, improve the random write performance, and improve the service life of the SSD.
(4) A Flash memory File System (F2FS) is a storage architecture of files on an operating System, and is a novel open source Flash File System specially designed for NAND-based storage devices. F2FS supports the Linux operating system. The flash memory device is suitable for NAND flash memory devices (such as solid state disk, eMMC, SD card and the like), namely, the flash memory device is more suitable for the current mobile terminal devices.
(5) The META tag is an important HTML tag in HTML web page source code. META tags are used to describe attributes of an HTML web document such as author, date and time, web page description, keywords, page refreshes, etc.
(6) The Most Significant Bit (MSB) is in the binary number, MSB is the Most Significant weighted Bit. Similar to the leftmost digit in a decimal number. Typically, the MSB is located on the leftmost side of the binary number.
(7) The abbreviation for Least Significant Bit (LSB), the LSB being the least weighted bit in the binary number. Similar to the rightmost digit in a decimal number. Typically, the LSB is located on the rightmost side of the binary number.
(8) An operation code (OP), an instruction, actually includes two kinds of information, an operation code and an address code. The OP is used to indicate the operation (e.g., add, subtract, multiply, divide, data transfer, etc.) to be performed by the instruction, and its length depends on the number of instructions in the instruction system. The address code is used to describe the operand of the instruction, either directly giving the operand or indicating the memory address or register address (i.e. register name) of the operand.
(9) Double Data Rate (DDR), DDR SDRAM (Synchronous Dynamic Random Access Memory), is an abbreviation of Synchronous Dynamic Random Access Memory (SDRAM), and DDR SDRAM is an abbreviation of Double Data Rate (SDRAM), which means DDR. DDR memory is developed on the basis of SDRAM memory, and SDRAM production system is still used, so for memory manufacturers, DDR memory production can be realized only by slightly improving equipment for manufacturing common SDRAM, and cost can be effectively reduced.
(10) Physical Extent (PE) each Physical Volume is divided into basic units called PEs, and a PE with a unique number is the smallest unit that can be addressed by Logical Volume Manager (LVM). The size of the PE is configurable, with a default of 4 MB.
(11) Failure rate refers to the probability of failure occurring in a unit time after a product which has not failed at a certain time is worked. Generally denoted as λ, which is also a function of time t, and hence also denoted as λ (t), is referred to as a failure rate function, and sometimes also as a failure rate function or risk function.
First, the technical problems to be specifically solved by the present application are further analyzed and presented. In the field of flash memory storage technology, SLC Buffer storage technology related to the present application includes two main technologies:
the first technology is as follows: dynamic and static SLC Buffer technology
The dynamic and static SLC Buffer technique provides high-speed write buffering to the host with a high-speed reliable SLC Buffer construction prior to low-speed, high-capacity TLC. Wherein, the SLC Buffer can be further subdivided into: static SLC Buffer and dynamic SLC Buffer, the space that static SLC Buffer provided is fixed, and the space that dynamic SLC Buffer provided can be along with remaining available space elasticity change. For example, static SLC Buffer utilizes NAND media supply industry conventions to fix the headspace (Over Provision) outside of the capacity specification for TLC (i.e., 128GB, 256GB …) to SLC mode at once. The dynamic SLC Buffer utilizes the characteristic that User Data Area (especially large capacity memory) is not full easily, and temporarily converts TLC into SLC to process the writing amount overflow scene of static SLC Buffer.
Referring to fig. 1A, fig. 1A is a diagram illustrating a data flow architecture of a dynamic SLC Buffer in the prior art. In this architecture:
1. the Host side (Host) writes (write) data, and enters Static SLC Buffer first.
2. When the Static SLC Buffer is full, Host side (Host) data is written to the Dynamic SLC Buffer. Therefore, if the available space for storage is large, the space of the dynamic SLC Buffer can be correspondingly large; the available space is small, and the dynamic SLCBuffer space is correspondingly small.
3. The Host side (Host) initiatively initiates a Data Garbage Collection operation, or when the Host load is idle, effective Data enters a User Data Area (User Data Area) through Garbage Collection (GC) operation from a slave static SLC Buffer (including a static SLC Buffer and a dynamic SLC Buffer), and then resides in a main storage Area in an MLC/TLC form.
The defects of the first technology: dynamic and static SLC Buffer technology. Essentially, only the dynamic and static SLC buffers are used as temporary Buffer areas, that is, after garbage collection operation, all data can be collected to the user data area, hot spot data retention cannot be realized, cold and hot data migration to the SLC buffers cannot be realized, and in short, the high performance of SLC cannot be enjoyed by the reading performance of the hot spot data.
The second technology is as follows: SLC Zone technology
The SLC Zone technology only provides a few slcblocks to ensure high reliability of small I/O system metadata, and most data is based on TLC failure rate management direct write TLC (i.e. before direct write TLC, it is ensured that failure rate does not exceed standard). For example, partial TLC is temporarily converted to SLC to provide a stand-alone fast disc, taking advantage of the characteristic that User Data Area (User Data Area), especially mass storage, is not easily full. At this time, HOST represents 2 User Data areas, so that it can implement SLC Zone hot Data retention and cold-hot Data migration through HOST management.
Referring to fig. 1B, fig. 1B is a schematic diagram illustrating an SLC Zone technology in the prior art. In this architecture:
1. the Host (Host) side writes (Write) Data directly into the User Data Area 1(SLC Zone) or through the static SLC Buffer into the User Data Area 2. Data in the User Data Area1 does not enter the User Data Area2 in principle, thereby realizing the residence of hot Data in the User Data Area1 (i.e., SLC Zone).
2. When the static SLC Buffer is full, the valid Data enters User Data Area2 in TLC form through garbage recovery operation from the static SLC Buffer.
The defect of the second scheme is as follows: the SLC Zone technology is not a self-contained medium providing fast access areas, the User Data Area1 and the User Data Area2 cannot be resource independent at the back-end medium access level (for example, the User Data Area1 and the User Data Area2 share a read/write buffer on an SRAM in a storage controller, etc.), and the profit performance is not expected when real User scenes are read and written in a crossed manner. And since there are two write (write) channels under this architecture, which are physically one channel in reality and only logically two channels, it may cause a decrease in write processing performance, for example, mutual exclusion or mutual occupation. Thus, the benefits of SLC Zone technology, when SLC or other fast new media cannot be commercialized in a short period of time due to technology, cost, supply, etc., continue to fall short of expectations.
In summary, the technical problems to be solved by the present application include the following aspects: aiming at the limitation of the existing storage technology, a scheme for accelerating the reading/writing of the storage data is provided, and the scheme can be established on the mainstream technical trend (including a dynamic and static SLCBuffer technology), so that the comprehensive reading and writing performance of the flash memory is improved on the premise of lower cost, and particularly the reading performance of partial type data (such as thermal data) is improved.
Based on the foregoing, embodiments of the present invention provide a host and a storage device. Referring to fig. 2A, fig. 2A is a schematic structural diagram of a host and a storage device according to an embodiment of the present invention, where the host 10 may be any computing device generating data, such as a server, a personal computer, a tablet computer, a mobile phone, a personal digital assistant, an intelligent wearable device, and other various devices; the storage device 103 may be any non-volatile memory that provides storage/read data functionality for the host 10. In the embodiment of the present invention, the storage device 103 may be embedded in the host 10, may also be an independent device separately from the host 10, and may also be that the storage device 103 and the host 10 are co-located in one electronic device, which is not specifically limited in this application. The host 10 or the storage device 103 may be a chip or a chip set or a circuit board carrying the chip or the chip set, and the chip or the chip set or the circuit board carrying the chip or the chip set may operate under a necessary software drive. In particular, the amount of the solvent to be used,
the host 10 may include a processor (CPU) 100 and an internal memory 101. Optionally, a host controller 102 may be further included, and further, all physical devices on the application processing side, such as a power supply, other input/output controllers, and interfaces, which are not shown in fig. 2A, may also be included. Wherein,
the processor 100: an operating system, a file system (e.g., flash file system F2FS), an application program, or the like may be run to control various hardware or software elements connected to the processor 100 and may process various data and perform operations. The processor 100 may load the instructions or data stored in the storage device 103 into the internal memory 101, call the instructions or data that need to be operated into the processor 100 for operation, temporarily store the result in the internal memory 101 after the operation is completed, and store the instructions or data that need to be stored for a long time into the storage device 103 through the host controller 102. Processor 100 may include one or more processing units (also referred to as processing cores) such as: the processor 100 may include one or more of a Central Processing Unit (CPU), an application processing unit (AP), a modem processing unit, a Graphic Processing Unit (GPU), an image signal processing unit (ISP), a video codec unit, a digital signal processing unit (DSP), a baseband processing unit, a neural Network Processing Unit (NPU), and the like. The different processing units may be separate devices or may be integrated in one or more devices. Optionally, a memory may also be provided in processor 100 for storing instructions and data. In some embodiments, the memory in processor 100 is a Cache memory (Cache). The Cache may hold instructions or data that have just been used or recycled by the processor 100. If the processor 100 needs to reuse the instruction or data, it can be called directly from the Cache. Avoiding repeated accesses reduces the latency of the processor 100, thereby increasing the efficiency of the system. Further, processor 100 may also be implemented as a System on a Chip (SoC).
The internal Memory 101, which is typically a power-down volatile Memory, loses its stored contents when power is removed, and may also be referred to as a Memory or main Memory. The internal memory 101 in the present application includes readable and writable operating memory, which is used for temporarily storing operation data in the processor 100 and interacting data with the storage device 103 or other external memories, and can be used as a storage medium for temporary data of an operating system or other programs in operation. For example, an operating system running on the processor 100 transfers data to be operated on from the memory 101 to the processor 100 for operation, and the processor 100 sends out the result after the operation is completed.
The internal memory 101 may include 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 includes a Double Data Rate synchronous Dynamic Random Access Memory (DDR SDRAM), a second generation Double Data Rate synchronous Dynamic Random Access Memory (DDR2), a third generation Double Data Rate synchronous Dynamic Random Access Memory (DDR3), a fourth generation Low Power consumption Double Data Rate synchronous Dynamic Random Access Memory (Low Power Double Data Rate 4, LPDDR4), a fifth generation Low Power consumption Double Data Rate synchronous Dynamic Random Access Memory (Low Power Double Data Rate 5, LPDDR5), and the like.
A host controller 102 for managing and controlling communication between the host 10 and the storage device 103, and providing a standardized (e.g., universal flash storage UFS standard) interface for communication between the host 10 and the storage device 103. Specifically, the host controller 102 may transfer commands (e.g., write, read, erase, etc. commands) and data to the storage device 103 according to read/write, etc. requests issued by the processor 100, and feed back events (e.g., command completion events, command status events, hardware error events, etc.) to the host 10 according to the results of reading/writing data, etc. by the storage device 103. For commands or data issued from processor 100, host controller 102 may encapsulate the commands or data into packets that support a protocol, and for data received by host 10, host controller 102 may reverse the operation. Optionally, one host may support multiple host controllers (HostController) to support communication with storage devices of different protocols. In the embodiment of the present invention, the host controller 102 generates a write command, a read command, an erase command, and the like referred to in this application according to a protocol (e.g., UFS protocol) supported between the host 10 and the storage device 103, and carries a data type identifier of data in the generated command to indicate the type of data to the storage device 103. For details, reference will be made to the following detailed description of the data storage method, which will not be described in detail herein. Alternatively, the functions of the host controller 102 may also be integrated into the processor 100, that is, the processor 100 performs the above-mentioned functions of the host controller 102, which is not limited in detail herein.
The storage device 103 includes at least a first storage area 1031 and a second storage area 1032. Further, the memory device 103 may also include a memory controller 1033. In the embodiment of the present invention, the first storage area 1031 and the second storage area 1032 have different storage performances, so as to be respectively used for storing data with different performance requirements. Wherein,
the storage device 103, which is a non-volatile memory, does not lose its stored contents after power is turned off. The storage device 103 (including the first storage area 1031 and the second storage area 1032) may be used for long-term storage of instructions and data related to the operation of the host 10, such as a boot program, an operating system, application programs and data, and the like. Since the processor 100 in the host 10 cannot directly read instructions and data in the storage device 103 and cannot directly write instructions or data to the storage device 103, when executing a read (or load) command, the processor 100 actually temporarily loads the contents to be read (including instructions and/or data) stored in the storage device 103 into the internal memory 101 through the host controller 102, and then reads the contents from the internal memory 101 by the processor 100; when a write (i.e., storage) command is executed, the processor 100 actually temporarily writes data (including instructions and/or data) to be stored into the internal memory 101, and then stores the data from the internal memory 101 to the storage device 103 through the host controller 102. Therefore, the performance of the storage device 103, such as the read rate, the write rate, the erase times, the data retention capability, etc., has a great influence on the performance of the host 10, and determines whether the host 10 or the electronic device in which the host 10 is located can operate normally, stably, and efficiently. Since in this application, the storage device 103 at least includes the first storage area 1031 and the second storage area 1032, and the storage performance of the first storage area 1031 is better than that of the second storage area 1032, therefore, the embodiment of the present invention stores different types (i.e., different performance requirements) of data to be stored in different stages to the same or different storage areas based on the data type of the data to be stored, so as to ensure the read/write performance of the host 10 side during reading/writing data, thereby improving the overall operating efficiency of the host. This will be further explained in the following examples, which are not described in detail herein.
The storage device 103 may include one or more of Flash memory (e.g., NAND Flash memory, NOR Flash memory, etc.), universal Flash memory (UFS), embedded multimedia card eMMC, universal Flash memory multi-chip package upcp memory, embedded multimedia card multi-chip package eMCP memory, Solid State Drive (SSD), etc. In one possible implementation, the memory device 103 includes at least a first memory region 1031 and a second memory region 1032, and the first memory region 1031 includes one or more of a single-layer cell SLC memory region, a Fast NAND memory, a phase change memory PCM, and a 3D stacked phase change memory X3D, and the second memory region 1032 includes one or more of a multi-layer cell MLC memory region, a three-layer cell TLC memory region, a four-layer cell QLC memory region, and a five-layer cell PLC memory region. The storage media of the first storage region 1031 and the second storage region 1032 may be the same or different. Further, the storage device 103 may also include other storage media such as a Hard Disk Drive (HDD) or the like.
Optionally, when the storage media of the first storage area 1031 and the second storage area 1032 are different, for example, the first storage area 1031 is SLC flash memory, and the second storage area 1032 is MLC or TLC flash memory. As shown in fig. 2B, fig. 2B is a schematic structural diagram of a memory device according to an embodiment of the present invention, wherein the first memory area 1031 may include M blocks (blocks), each Block includes N pages (pages), each page includes a certain number of cells (cells), all cells in all pages of all blocks in the first memory area 1031 are single-layer cells (SLC), and thus the first memory area forms an SLC type memory area. Similarly, the second storage area may include L blocks, each Block includes N pages (the number may not be N), and each page includes a certain number of cells, and all the cells in all the pages in all the blocks in the second storage area 1032 are multi-level cells (MLC) or triple-level cells (TLC), so that the second storage area 1032 forms a MLC/TLC type storage area. I.e. the read latency, write latency and/or read-write reliability of pages (pages) in blocks (blocks) comprised in different types of memory areas are different.
Alternatively, based on fig. 2B, when the storage media of the first storage area 1031 and the second storage area 1032 are the same, and when the storage media are both MLC or TLC, a mode of converting a part of MLC or TLCBlock into SLC mode may be used. The reason is that MLC/TLC differs from SLC in that there are several bits of data in one cell, three bits for MLC, two bits for MLC, and 1bit for SLC. The conversion of MLC to SLC mode is done using only one of the two bits, the Least Significant Bit (LSB). The same principle applies for the TLC transition to SLC mode, using only the Least Significant Bit (LSB) of the three bits. Of course, so that no other one or two bits are used, the capacity equal to the other half or two thirds is not used. Therefore, the capacity of MLC is only half of that of original MLC after the conversion of MLC into SLC mode, and the capacity of TLC is only one third of that of original TLC after the conversion of TLC into SLC mode. Therefore, in the embodiment of the present invention, the reading and writing performance can be improved by switching part of the MLC/TLCBlock to the SLCBlock in the MLC/TLCNANDFlash-based solid-state storage device 103. That is, the first storage area 1031 and the second storage area 1032 are both MLC/TLC in nature, and the first storage area 1031 is an SLC storage area converted by MLC/TLC, and is mainly used to accelerate the writing speed of the newly written data and the reading speed of the subsequent portion of data (such as the first type of data). In summary, the size between the first storage area 1031 and the second storage area 1032 can be dynamically changed in the embodiment of the present invention, for example, 512 blocks exist in the entire storage device 103, and when there are 100 blocks in SLC mode, 412 blocks in MLC/TLC mode exist; when there are 200 blocks for SLC mode, then there are 312 blocks for MLC/TLC mode, and so on. That is, the number of SLC blocks can be set according to different requirements of data storage. Further alternatively, a portion of SLC blocks may be set as static SLC blocks and the remainder as dynamic SLC blocks in the converted SLC blocks. That is, no matter how the number of SLC blocks changes, the number of static SLC blocks is always the same (e.g., 40), while the number of dynamic SLC blocks can change according to the requirement. That is, the number of blocks in different storage areas can be determined according to the need of storing data.
It should be noted that Page is the smallest addressing unit in NAND Flash, i.e., the smallest unit for reading/writing. The number of pages in one Block is different according to different specifications of different manufacturers, and the size of the pages is different. For example, there are 1024 pages in a Block, and each page has a size of (16KB +2208B), where 16KB is a data area for storing data, 2208B is a metadata area for storing metadata, such as 16KB for storing one or more target data in the application, and 2208B is for storing data type identifications corresponding to the one or more target data, respectively. The erasing performance of the SLC and the MLC is similar, and the reading performance (including reading speed), the writing performance (including writing speed) and the storage performance (including storage life) of the SLC flash memory are better than those of the MLC/TLC flash memory.
Referring to fig. 2C, fig. 2C is a user interface diagram of some adjustment cache areas and general areas according to an embodiment of the present invention, in the user interface 21, a user clicks a setting button 201 to enter a user interface 22 of a system setting function, and the user further clicks an option storage management 202 to enter a user interface 23 of partition management. The user may adjust the current size of the cache region (i.e. the first memory region 1031 in this application, such as the SLC memory region) by an "increase" button 203 or a "decrease" button 204. Since the total storage space of the storage device 103 is fixed, the size of the normal region (i.e. the second storage region 1032 in this application, such as an MLC/TLC storage region) can be indirectly adjusted by adjusting the size of the "cache region". Therefore, it is possible to display the current size of the normal area in the storage device 103 only through the display box 205, and prompt the user through the prompt information 206 to: "the total storage space is 512G, wherein the cache region is converted from the normal region, and the size after conversion is one half of the original normal region". It is understood that the cache area may include a static cache area (e.g., static SLC storage area) and a dynamic cache area (e.g., dynamic SLC storage area), and since the static cache area may be considered as a fixed size (e.g., 4G), the user may adjust the size of the dynamic cache area in the cache area. In a specific situation, a user can set the size ratio between the cache area and the common area according to the use requirement of the user, and the embodiment of the present invention is not particularly limited.
The memory controller 1033 is an interface device between the host 10 and the memory device 103, and mainly functions to perform interface conversion, convert commands such as read, write, delete, etc. issued by the host 10 (for example, a host controller in the host 10) into signals that can be recognized by the memory device 103, and also perform address decoding between the host 10 and the memory device 103 (for example, mapping between logical addresses of the host 10 and physical addresses in the memory device 103), data format conversion (for example, data bit width), and the like. In summary, the memory controller 1033 can perform necessary control of the access of the memory device 103 in which it is located according to a certain timing rule, including control of address signals, data signals, and various command signals, so that the host 10 can use the memory resources on the memory device 103 according to the requirement. For example, the memory controller 1033 receives and analyzes a read command or a write command sent by the host controller 102 in the host 10, and according to a logical address of data carried in the read command or the write command, the logical address of the data is analyzed as a physical address according to a fixed address mapping relationship, so as to search a position of the data to be read or written, and finally send a control signal corresponding to the command to the first storage area 1031 or the second storage area 1032.
It should be noted that a computer program (referred to as a data storage program for short, and may include related instructions and related data, and will not be described repeatedly later) for implementing any data storage method in the present application relates to and includes a multi-part function, one of which is a determination (including identification, storage management, and the like) of a data type of data to be stored by the host 10 side, and a processing procedure indicating the data type of the data to be stored in a write command; the other part is the processing procedure of the storage device 103 side for receiving the data to be stored, performing preliminary storage and subsequent storage space recovery. The data type identification function may be implemented by a data identification program in an operating system run by the processor 100, the storage management function after data type identification may be implemented by a file system (e.g., F2FS) in the operating system run by the processor 100, the function of indicating the data type of the data may be implemented by a control program run by the host controller 102, and the function of storing the data (including initial storage and subsequent space reclamation) may be implemented as a control program run by the storage controller 1033. Finally, by the multi-part function included in the above-described data storage program, a function of performing high-performance data storage between the host 10 and the storage device 103 is realized. This will be further explained in the following examples, which are not described in detail herein. The file system refers to a software mechanism in the operating system, which is responsible for managing and storing file information.
It is understood that the structures of the host 10 or the storage device 103 in fig. 2A or fig. 2B are only some exemplary implementations provided by the embodiments of the present invention, and the structures of the host 10 and the storage device 103 in the embodiments of the present invention include, but are not limited to, the above implementations.
It is further understood that the processor 100 and the internal memory 101, the host controller, and the storage device 103 may communicate with each other through a system bus, and may also communicate through other connection manners, which is not specifically limited in this embodiment of the present invention. The illustrated structure of the embodiment of the present invention does not constitute a specific limitation of the host 10 or the storage device 103. In other embodiments of the present application, the host 10 or the storage device 103 may include more or fewer components than shown, or some components may be combined, some components may be split, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Further, when the host 10 and the storage device 103 are both taken as a part of the electronic device 20 (i.e. are co-located in the same electronic device 20), please refer to fig. 2D, where fig. 2D is a schematic structural diagram of an electronic device according to an embodiment of the present invention, and the electronic device 20 or the host 10 part in the electronic device 20 may further include the following functional modules:
the external memory interface 104 may be used to connect an external memory card, such as a tf (transflash) card, also known as a T-Flash card, a Flash drive, a Compact Flash (CF), a Secure Digital (SD), a micro SD, a mini SD, an ultra digital (xD), a multimedia card (MMC), a memory stick, and the like. The external memory card is operatively and/or physically connected to the electronic device 20 through the external memory interface 104 to expand the memory capabilities of the electronic device 20. For example, files such as music, video, etc. are saved in an external memory card.
And a SIM card interface 105 for connecting a SIM card. The SIM card can be brought into and out of contact with the electronic device 20 by being inserted into the SIM card interface 105 or being pulled out from the SIM card interface 105. The electronic device 20 may support 1 or N SIM card interfaces, N being a positive integer greater than 1. The SIM card interface 105 may support a Nano SIM card, a Micro SIM card, a SIM card, etc. The same SIM card interface 105 can be inserted with multiple cards at the same time. The types of the plurality of cards may be the same or different. The SIM card interface 105 may also be compatible with different types of SIM cards. The SIM card interface 105 may also be compatible with external memory cards. The electronic device 20 interacts with the network through the SIM card to implement functions such as communication and data communication. In some embodiments, the electronic device 20 employs esims, namely: an embedded SIM card. The eSIM card can be embedded in the electronic device 20 and cannot be separated from the electronic device 20.
A display screen 106 for displaying text, images, audio, etc. The display screen 106 includes a display panel. The display panel may adopt a Liquid Crystal Display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (active-matrix organic light-emitting diode, AMOLED), a flexible light-emitting diode (FLED), a miniature, a Micro-oeld, a quantum dot light-emitting diode (QLED), and the like. Further, the display screen 260 may include a touch screen, and may receive touch, gesture, proximity, hover, or the like input from the electronic pen or a portion of the user's body. In some embodiments, the electronic device 20 may include 1 or N display screens 194, with N being a positive integer greater than 1.
The audio system 107 may include speakers, receivers, microphones, headphone interfaces, and the like. The electronic device 20 may implement audio functions through the audio system 107 and the AP or the like in the processor 100. Such as talking, music playing, recording, etc.
The camera system 108, which may include one camera (camera) or a plurality of cameras (e.g., one front camera and one rear camera, or a plurality of front cameras and a plurality of rear cameras), may also be a set of camera modules. The camera is used to capture still images or video. The electronic device 20 may implement a camera, an ISP in the processor 100, a video codec, a GPU, an AP, and a display screen 106, among other things, to implement a shooting function.
The sensor system 109 may include a four-in-one (accelerometer, angular velocity, gyroscope, compass) motion sensor, pressure sensor, temperature sensor, light sensor, proximity light sensor, 3D structured light sensor, and the like. Different sensors are used for sensing different signals, so that the processor 100 performs operation processing according to different sensing signals to realize different functions of the electronic device 20. For example, a four-in-one motion sensor may be used to determine motion pose and orientation information, etc. of electronic device 20; the light sensor is used for sensing the ambient light brightness, and the electronic device 20 may adaptively adjust the brightness of the display screen 106 according to the sensed ambient light brightness, or may be used for automatically adjusting the white balance when the photographing system 108 photographs.
The communication system and the wireless communication function of the electronic device 20 may be implemented by the antenna 1, the antenna 2, the mobile communication module 110, the wireless communication module 111, a modem processor, a baseband processor, and the like. The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. The mobile communication module 110 may provide a solution including 2G/3G/4G/5G wireless communication applied on the electronic device 20. The wireless communication module 111 may provide a solution for wireless communication applied to the electronic device 20, including Wireless Local Area Networks (WLANs) (e.g., wireless fidelity (Wi-Fi) networks), bluetooth (bluetooth, BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), and the like.
A power management module (PMU)110 may manage power for electronic device 20. The power management module 112 receives input from the battery 113 and/or the charging management module 114, and supplies power to the processor 100, the internal memory 101, the host controller 102, the storage device 103, the display screen 106, the audio system 107, the camera system 108, the sensor system 109, the mobile communication module 110, the wireless communication module 111, and the like. The charging management module 114 may employ wired and/or wireless charging methods. The wireless charging method may include, for example, a magnetic resonance method, a magnetic induction method, an electromagnetic method, and the like. The battery 113 may include a rechargeable battery and/or a solar cell, etc.
It is to be understood that the illustrated structure of the embodiment of the present invention does not specifically limit the electronic device 20. In other embodiments of the present application, the electronic device 20 may include more or fewer components than shown, or combine certain components, or split certain components, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The data storage method provided by the embodiment of the present invention will be specifically described below with reference to the structures of the host 10 and the storage device 103 shown in fig. 2A-2B and the structure of the electronic device 20 shown in fig. 2D. In the data storage method provided by the embodiment of the present invention, the related processes of storing data into the storage device 103 and reading data from the storage device 103 by the host 10 are involved. Specifically, when the host 10 needs to write target data into the storage device 103, it needs to indicate a data type of the target data to the storage device 103 and carry the data type in a write command, and the storage device 103 stores the target data (including a corresponding data type) into the first storage area 1031 with better performance in a unified manner to ensure fast performance of data when initially writing, and then needs to further determine the data type of the data to be recovered when performing storage space recovery (which may also be referred to as garbage recovery in some application scenarios) on part or all of the data (including the target data) in the area due to, for example, limited space of the first storage area 1031. If the target data belongs to a first type with a higher requirement on the storage performance, the target data is continuously retained in a first storage area 1031 with a better performance, and if the target data belongs to a second type with a lower requirement on the storage performance, the target data is moved to a second storage area 1032 with a relatively weaker performance for storage, so as to ensure the reading performance of the host 10 for subsequently reading data from the storage device 103, thereby achieving the purpose of improving the overall operation performance of the host 10.
The type of the data to be stored is determined and indicated by the host 10; and how the storage device 103 stores the data to be stored according to the data type, the data storage method provided by the present application is specifically described.
How the host 10 determines and indicates the type of data to be stored
In the embodiment of the present invention, how the host 10 determines and indicates the type of data to be stored will be described from the following points: 1. how the host determines the data type of the data to be stored; 2. how the host specifically indicates the data type of the data to be stored; 3. how the write command is sent to the storage device 103. Wherein
1. How a host determines the data type of data to be stored
After the host 10 is powered on and operated, data (including instructions or data) needs to be read from the storage device 103, that is, the processor 100 first loads corresponding data from the storage device 103 to the internal memory 101 through the host controller 102, and then the processor 100 in the host 10 can be loaded and operated, for example, the read data includes related instructions and data of a boot program, an operating system, and an application program (e.g., a social application, a video application, a music application), and the like; when the host 10 needs to write data to be stored into the storage device 103, the processor 100 needs to write the processed result into the storage device 103 from the temporary internal memory 101 for long-term storage, for example, the data to be stored includes system logs, documents edited by a user, downloaded videos, music, and historical data of common software.
In the embodiment of the present invention, the data to be stored, which the host 10 needs to write to the storage device 103, is divided into at least a first type and a second type, and the storage performance requirement of the first type of data is higher than that of the second type of data. Specifically, the data read/written by the host 10 generally relates to system data and user data, where the system data generally includes an operating system (including a Linux kernel and an Android operating system, for example), a file system, a system-in application program (such as an application market, a wallet application, a security center, and the like) which is shipped from the host, system data (such as configuration file data, log file data, cache data, and the like) related to system operation, and the like, which are executed by the host 10. The user data generally includes application programs (such as social application, video application, mobile payment application, game application, and the like) which are downloaded and installed by the user after the user leaves the factory, data generated in the using process (such as music, photos, videos, contact information, chat records, browsing records, documents, password data, cache data of each application, and the like), and the like.
In an embodiment of the present invention, the data for the first type may include one or more of the following:
(1) high-frequency access databases, i.e. databases that may be read or written with high frequency, such as photo databases, video databases, document databases, etc. When a user frequently clicks on an album to view pictures, frequently views videos, or frequently edits a document save document, etc., through the host 10 side, the corresponding database stored in the storage device 103 is frequently accessed (read or written) by the host 10 side. Therefore, in the embodiment of the present invention, the data may be set as the first type of data, so as to be subsequently resident in the first storage area with better performance, thereby enabling the part of data to achieve faster read-write efficiency, further ensuring better performance such as read/write, and so on, and improving the overall performance of the host 10.
(2) And data of common applications, such as game applications, social applications, photographing applications, and data related to art applications commonly used by users. When a user frequently starts a game application to play a game, opens a social application to chat, opens a photographing application to take a picture, and starts a beauty application to repair, beautify and the like the taken picture, the related data of the corresponding application stored in the storage device 103 is frequently accessed (read or written) by the host 10 side. Therefore, in the embodiment of the present invention, the first type of data may be set, so as to facilitate subsequent passing through the first storage area with better performance, thereby enabling the part of data to achieve faster read/write efficiency, and further ensuring that better performance such as read/write is provided for the part of data, so as to improve the overall performance of the host 10.
The data of the database or the common application with high frequency access may be obtained by the operating system on the host 10 side automatically judging or counting according to the frequency of the application used by the user, or may be set by the user according to the preference of the user, for example, an application that the user needs to use frequently, or the user considers important, or the user wishes to improve the experience. Referring to fig. 3A, fig. 3A is a schematic diagram of some interfaces for users to perform fast mode setting according to an embodiment of the present invention, in a user interface 31, a user enters a user interface 32 of a system setting function by clicking a setting button 301, and the user further clicks option storage management 302, thereby entering a user interface 33 of fast mode management. The user may select the application by selecting a switch control for each application, such as the switch control 303 of the gallery,
Figure BDA0002476939490000217
The switch control 304,
Figure BDA0002476939490000218
Switch (2)A control 305, a music switch control 306, and the like, for turning on or off the "fast mode" for each application. And alerts the user through prompt 307 to: "when the fast mode is turned ON (ON), the application can be stored in the" fast zone "for a long time (i.e. the first storage area in this application), and a faster and better experience is enjoyed when starting or running", it being understood that when the fast function is turned off, the application will be stored in the "normal zone" for a long time (i.e. the second storage area in this application), and the starting or running is relatively slow. For example, when a gallery is combined with
Figure BDA00024769394900002112
After the "fast mode" function is turned ON (ON), that is, when the switch controls 303 and 305 are in the ON state, the electronic device 20 will connect the gallery with the other gallery
Figure BDA0002476939490000219
The application-related data is set to a first type such that the gallery and
Figure BDA00024769394900002111
the relevant data of the application is not only initially stored in the first storage area 1031, but also can continue to reside in the first storage area 1031 after subsequent space recovery, and when the data needs to be read out from the storage device 103, the data can be directly read out from the first storage area 1031 to achieve a "fast mode"; while
Figure BDA00024769394900002110
And music switch controls 304 and 306 are in the OFF state, then the data for that application is also initially stored in the first storage area, but after the space reclamation operation is performed, it is reclaimed to the slower "normal" or second storage area 1032. In a specific situation, a user can set an application which is desired to reside in the fast zone according to the use habit or the requirement of the user, and the application is not listed one by one.
(3) Metadata of a file system, data in any file system is divided into data and Metadata (Metadata). The data refers to actual data in a common file, namely the actual content of the file; and metadata refers to system data used to describe characteristics of a file, such as access rights, file owner, and distribution information of file data blocks (e.g., inode). The host 10 needs to operate a file in the file system to first obtain its metadata to locate the file and obtain the content or related attributes of the file. Since the role of the file system is to determine how to store and retrieve data in the local storage. For example, flash file system (F2FS), F2FS, has a "Meta" field that contains various metadata. When the host 10 side needs to perform any read or write operation in the storage device 103, a subsequent operation needs to be performed based on metadata in the file system as an index. Therefore, in the embodiment of the present invention, the metadata (i.e., F2FS META) of the file system may be set as the first type of data, so as to be able to subsequently pass through the first storage area 1031 with better performance, thereby enabling the metadata to be read or written by the host 10 more efficiently, and the host 10 responds to all subsequent operations faster, thereby ensuring better performance of reading/writing, etc., so as to improve the overall performance of the host 10.
(4) Swap (Swap) partition data, the Swap partition, also known as virtual memory, is a partition that is partitioned from storage device 103. When the actual memory (i.e. the physical memory, corresponding to the memory 101 in this application) is not enough, the operating system will take a part of the temporarily unused data from the memory and place the part in the Swap partition Swap, thereby making up enough memory space for the currently running program. That is, when the real memory is not enough, the Swap partition is used to temporarily replace the virtual memory. The released memory space may come from programs that do not have any operation for a long time or from applications that fall back to the background during operation of the mobile phone. Alternatively, in the field of mobile terminals, a Swap partition (Swap) is also commonly set in the internal memory 101 (also referred to as a ZRAM space), and these released programs are temporarily saved in the Swap partition (e.g., with a resilience size of 300MB to 2GB) of the internal memory 101, for example, data may be compressed by about 3:1 and then saved in the Swap partition, and when the part of programs needs to be run, the saved data is restored from the Swap partition to a normal partition of the memory.
That is, when the host 10 side has insufficient space in the memory (i.e., the internal memory 101) or in the normal partition of the memory, a portion of data currently stored in the internal memory 101 needs to be temporarily stored in the internal memory 101 or the Swap partition of the storage device 103 as Swap partition data, and the portion of Swap partition data may be restored to the internal memory 101 at any time. Therefore, in the embodiment of the present invention, the part of the Swap partition data may be set as the first type of data, so that the first type of data may reside in the first storage area with better performance for a long time after being transferred to the external memory (the storage device 103), and when the operating system accesses the part of data again, the Swap partition data is quickly restored from the first storage area 1031 to the internal memory 101, so that the part of data realizes faster read-write efficiency, and further, better performance such as read/write is ensured, so as to improve the overall performance of the host 10. It should be noted that the Swap partition data does not refer to some fixed data, but refers to data loaded into the Swap partition in any case, that is, the Swap partition data in different cases may have different corresponding data.
That is, in the embodiment of the present invention, the first type of data may be data that is more sensitive to the reading performance or data that is more sensitive to the reading and writing performance, so as to reduce the reading response time of the first type of data subsequently, so as to improve the user experience.
In the embodiment of the present invention, the data for the second type may include one or more of the following cases:
(1) data with a large amount of data, such as video data, audio data, and the like downloaded by a user.
(2) Low frequency access databases, for example, databases that may be less frequently read, such as document databases, video databases, and the like.
(3) Data of unusual applications, e.g. data related to sports applications, forum applications, take-away applications, etc. that are not commonly used by the user, etc.
Alternatively, the second type of data may be all data other than the first type of data processed by the host 10. Since the requirement of the second type of data on the storage performance is lower than that of the first type of data, the initial fast writing performance can be ensured by initially storing the second type of data in the first storage area, and when the space of the first storage area is recycled due to the limited space of the first storage area and the like, the second type of data is recycled in the second storage area for long-term storage, and the first storage area is left as far as possible for the first type of data with higher requirement on the storage performance. In a possible implementation manner, the first type of data may also be hot data (i.e., data with high read/write frequency or data with high activity), and the second type of data may be cold data (i.e., data with low read/write frequency or data with low activity).
That is, the host 10 may determine whether the data belongs to the first type or the second type according to one or more of the characteristics of the write frequency, the read frequency, the expected read performance, the expected write performance, the expected data retention duration (for example, how long the data is expected to be stored in the storage system), the type of the data, the attribute of the data, and the like of the data, and further determine the storage area corresponding to each class of data at different stages.
Referring to fig. 3B, fig. 3B is a schematic structural diagram of another electronic device according to an embodiment of the present invention, for example, the first storage area is an SLC storage area (that is, the first storage area includes a plurality of SLC blocks), the second storage area is an MLC/TLC storage area (that is, the second storage area includes a plurality of MLC/TLC blocks), and the first type of data and the second type of data may be initially written into the SLC storage area 1031 under the control of the storage controller 1033 when the host 10 side writes into the storage device 103, and after a subsequent storage space reclamation operation, the first type of data is continuously resident in the physical Block of the SLC storage area 1031, and the second type of data is reclaimed into the physical Block of the MLC/TLC storage area 1032.
In a possible implementation manner, the identification of the data type of the first type or the second type may be implemented by a related data detection engine (software function module) in an operating system run in the host 10, and after the identification is completed, the type information of the data may be saved and managed by a file system (e.g., F2FS) in the operating system run by the host 10, and when the subsequent host 10 needs to indicate the data type of the data to be stored to the storage device 103, the subsequent host may learn from the data type information saved and managed in the file system through the host controller 102, and generate a write command carrying an identifier of the corresponding data type.
It should be noted that whether the data is of the first type or the second type may be set differently according to the type of the host 10 or the type of the electronic device 20. For example, when the electronic device is a mobile terminal, the first type of data may include data of common applications, and when the electronic device is an intelligent wearable device, the first type of data may include a database or the like accessed at a high frequency. Furthermore, different time periods or different modes of the electronic device 20 may result in different corresponding first or second types of data. That is, the same type of data may have different requirements on the storage performance in different hosts 10 or electronic devices 20, or in different time periods and different modes in the same host 10 or electronic device 20, so that the definition of the first type or the second type of data in different hosts 10 or electronic devices 20 is different, which is not illustrated herein.
2. How the host specifies the data type of the data to be stored
In the data storage method in the embodiment of the present invention, after the type of the data is determined, the host 10 may store the type information corresponding to the data in the file system, and when the data needs to be stored in the storage device 103, carry the type information (i.e., the data type identifier) of the related data stored in the file system in the write command, so as to indicate the first type or the second type, etc. corresponding to the data to be stored. Alternatively, the data type identifier may be stored in file system Metadata (META), and the metadata of the file system is either flushed to an external memory (i.e., the storage device 103) for long-term storage or imported into the internal memory 101 for use during the operation of the host. That is, it can be understood that the host 10 indicates the type of the data to be stored to the storage device 103 by marking a data type tag on the data to be stored through the host controller 102, so that when data in the storage device 103 is subsequently recovered by the storage space, the data can be once again or permanently resided in the first storage area with better performance by means of the data type identifier of the first type. Optionally, the host 10 may determine the type of the data at an initial generation stage of the data, or determine the data type of the data before the data is stored in the storage device 103, and finally, indicate the data type of the data by carrying the data type identifier of the data in a preset position of a write command sent to the storage device 103.
Referring to fig. 4A, fig. 4A is a schematic diagram illustrating a write command format according to an embodiment of the invention. For example, the command format shown in fig. 4A is a WRITE command format complying with Universal Flash Storage (UFS), named Table11-30-WRITE (10) command, and for example, the command format may carry a data type identifier on a Reserved field corresponding to Reserved bit 1, Reserved bit 2, or Reserved bit 3. Optionally, any reserved bit not occupied by the standard protocol in the above-mentioned WRITE command or other types of UFS WRITE commands may also carry the data type identifier in this application, for example, the WRITE command has, in addition to the WRITE (10) shown in fig. 4A, the formats of WRITE (6), WRITE (16), and the like, which are not listed here. As shown in FIG. 4A, the write command comprises 10 bytes, from Byte0 to Byte9, each of which has 8 bits (bit) of 0-7, and the 1 st Byte, Byte0 → for indicating an operation code, i.e. the Byte is used for indicating read, write or erase operations; byte1 of Byte2 → control Byte, which is used to limit the state that the operation corresponding to the operation code needs to reach, such as write protection; bytes 3-6, Byte 2-5, are used to indicate a logical block Address (logical block Address), that is, to write the data of the logical block Address in the memory (memory 101) into the space of the flash memory (storage device 103); byte6, Byte7, is used to indicate the Group Number (Group Number) and Reserved bit (Reserved); the 8 th to 9 th bytes are Byte7 to Byte8 for indicating the length of the data to be stored; byte9, Byte 10, is also a reserved control bit. Before the Host 10 writes data (for example, target data) into the storage device 103, the data type of the target data stored in the file system may be obtained in advance by the Host controller 102, and then when the data needs to be written into the storage device 103, the Address of the target data in the memory is indicated by indicating the Logical Block Address, the transfer length, and the like of the target data in the memory of the Host 10Host in the write command, and the target data is indicated as data of the first type or the second type by the data type identifier carried in the reserved bits in the write command. After receiving the write command, the storage device 103 parses the write command through the storage controller 1033, thereby determining an address and a data type of target data to be written, and stores the target data and a corresponding data type identifier in the first storage area 1031 of the storage device 103, and when performing a storage space reclamation (such as garbage reclamation) operation subsequently, it may further determine whether to continue to reside the target data in the first storage area or to reclaim the target data to the second storage area according to the stored data type identifier, and according to the data type of the target data. In one possible implementation, the first type corresponds to hot data, the corresponding data type identifier is a hot tag, the second type corresponds to cold data, the corresponding data type identifier is a cold tag, the first storage area corresponds to an SLC storage area (which may include a static SLC storage area and a dynamic SLC storage area), and the second storage area corresponds to an MLC/TLC storage area. Then initially, either cold data or hot data is stored in the SLC memory region (static SLC memory region or dynamic SLC memory region), and when garbage collection is performed, hot data continues to reside in the SLC memory region (static SLC memory region or dynamic SLC memory region), while cold data is collected in the MLC/TLC memory region.
Referring to fig. 4B, fig. 4B is a schematic diagram of another write command format provided in the embodiment of the present invention, where the write command is a data packet conforming to a Universal Flash Storage (UFS) Protocol, and is referred to as a UFS Protocol Information Unit (UPIU), where the UPIU is a data structure with a fixed format and is used to transmit commands or requests from an application layer and data or status Information related to the commands or requests. It is understood that a UPIU is a carrier for the transmission of command, data, and status information. That is, the corresponding WRITE command in FIG. 4A may be encapsulated or carried in the data packet in CMD UPIU format provided in FIG. 4B, for example, the WRITE (6) uses (carried in) the CDB [0] to CDB [5] bytes in FIG. 4B, the WRITE (10) uses (carried in) the CDB [0] to CDB [9] bytes, and the WRITE (16) uses (carried in) the CDB [0] to [15] bytes. A UPIU is a packet with a fixed format, where the CMD UPIU packet may carry a logical partition number (logical unit number) of data in certain bytes (illustrated byte [2 ]). When an explicit fast-slow dual partition is present on the host side to an Operating System (OS), the data may also be identified by a LUN number, for example, a physical space managed by a file system is divided into a LUN3 and a LUN4, data stored in the LUN4 is data expected to be read quickly, data stored in the LUN3 is data expected to be read commonly, the logical partition number may be identified as a data type of the first type of data or the second type of data in the present application, that is, data with a logical partition number of LUN4 corresponds to the first type, data with a logical partition number of LUN3 corresponds to the second type, that is, at this time, the data type identifier of the data is a logical partition number of the data, and different logical partition numbers represent data with different storage performance requirements (especially random read or write performance). It will be appreciated that other bytes in the command are not described in detail herein.
In summary, in the embodiment of the present invention, the data type of the data to be stored may be indicated by a preset bit in the write command or a logical partition number in the write command after being encapsulated.
How to store data to be stored according to data types on the storage device 103 side
In the embodiment of the present invention, how the storage device 103 side stores data to be stored according to data types will be described from the following points: 1. the storage equipment receives the write command and analyzes the write command; 2. storing the data to be stored and the corresponding data type according to the analyzed write command; 3. how to recover or reside the data to be recovered when the storage space is recovered; the Host side Host reads data in the storage device 103 specifically. Wherein
1. The storage device 103 receives the write command and parses the write command
After receiving the write command sent by the host 10, the storage device 103 writes the data to be stored (such as the target data) and the corresponding data type identifier into the first storage area 1031 in the storage device 103 by parsing the write command. That is, in the data storage method in the embodiment of the present invention, the host 10 side marks all data with a tag of a first type or a second type, for example, a cold data tag or a hot data tag, and the storage controller 1033 on the storage device 103 side parses the write command (including parsing the address and the data type in the write command), and stores the data and the data type identifier according to the parsed write command.
2. Storing the data to be stored and the corresponding data type according to the analyzed write command
When the Host (Host)101 writes data into the storage device 103, there are two cases, i.e., one is newly written (newly added) data; the other is to rewrite (or to be called to rewrite) existing data. The different types of data writing methods may result in different processing methods for the data by the memory controller 1033. Wherein,
(1) newly written (newly added) data
For newly written data, there is a possibility that the newly written target data may be written into a completely free physical Block (Block) or a partially free physical Block, but since the newly written data is in units of pages, it is possible to write into free pages in any one or more blocks. Since the data is initially written, the data of the first type or the data of the second type are written into a physical Block (Block) in the first memory area 1031, so that the fast write performance provided by the first memory area 1031 can be enjoyed.
Referring to fig. 5A-5C, fig. 5A-5C are schematic diagrams illustrating some embodiments of the present invention for writing new data into a Static SLC memory region of a memory device, for example, as shown in fig. 5A, when the first memory region 1031 is an SLC memory region, and further optionally, the SLC memory region includes a Static SLC memory region (Static SLC buffer) and a Dynamic SLC memory region (Dynamic SLC buffer), wherein the Static SLC memory region includes T SLC blocks, the Dynamic SLC memory region includes S SLC blocks, T is a fixed size, and S is a variable size. As shown in fig. 5B in particular, the newly written target data may be written to a physical Block in a static SLC storage area in the SLC storage area 1031, such as to free pages 1 and Page2 in Block1 of the static SLC storage area. In one possible implementation, as shown in fig. 5C, each physical Page (Page) in each Block includes a data area and a metadata area, and at this time, the target data itself and the corresponding data type identifier may be stored in the data area and the metadata area, respectively, for example, data 2 is written into a free physical Page1, the corresponding data type identifier is written into a corresponding metadata area (identifier 2), data 3 is written into a free physical Page2, and the corresponding data type identifier is written into a corresponding metadata area (identifier 3).
Referring to fig. 6A-6C, fig. 6A-6C are schematic diagrams of some embodiments of writing new data into a dynamic SLC memory area of a memory device, and optionally, as shown in fig. 6A, the newly written target data may be written into a physical block in the dynamic SLC memory area 1031. Specifically as shown in fig. 6B, such as to free pages 2 and Page3 in Block2 in the dynamic SLC storage area. In one possible implementation, as shown in fig. 6C, each physical Page (Page) in each Block includes a data area and a metadata area, and at this time, the target data itself and the corresponding data type identifier may be stored in the data area and the metadata area, for example, data 3 is written into a free physical Page2, the corresponding data type identifier (identifier 3) is written into the corresponding metadata area, data 4 is written into a free physical Page3, and the corresponding data type identifier (identifier 4) is written into the corresponding metadata area.
Further optionally, the newly written target data may be preferentially written into the static SLC storage area, and only written into the dynamic SLC storage area when the static SLC storage area is full or reaches a certain storage amount. Where Static SLCbuffer is typically a fixed size, e.g., fixed to 2G, and the storage size of the Dynamic SLCbuffer is adjusted according to the size of the second storage area, e.g., MLC/TLC. That is, the size of the Dynamic SLC Buffer may be adjusted according to the size of the remaining available space in the storage device 103, and the larger the remaining space is, the Dynamic SLC Buffer area may be correspondingly enlarged, for example, according to MLC/TLC: SLC ═ 3:1 switching relationships.
(2) Overwriting (or called duplicating) existing data
Referring to fig. 7A to 7C, fig. 7A to 7C are schematic diagrams of some existing data being rewritten to a dynamic SLC storage area of a storage device according to an embodiment of the present invention, and for a case of rewriting existing data, according to a storage principle and characteristics of a Flash memory (Flash), it is necessary to write the rewritten data into a new physical block (instead of directly modifying in an original data page), and then set a corresponding page to be modified in a source data block as invalid, while other unwritten data in the source physical block is temporarily not processed first, and when a storage space is subsequently recycled (e.g., garbage is recycled), the data is then uniformly moved. As shown in fig. 7A, assuming that data in Block1 in the static SLC storage area needs to be rewritten and finally updated in Block S-2 in the dynamic SLC storage area in a different place, specifically as shown in fig. 7B, assuming that it is currently necessary to rewrite (data 1 and data 3) for Page0 and Page2 of Block1 stored in the static SLC storage area, newly writing contents (data 1 'and data 3') to be rewritten into free pages Page0 and Page1 in the dynamic SLC area (which may be a completely free physical Block or a partially free physical Block), setting data in Page0 and Page2 in Block1 before rewriting as invalid, and for data that does not need to be rewritten (such as data 2 in Page1 and data 4 in Page3 in Block1, etc.), remaining in the original Block1 until Block1 returns, garbage-moving valid data in Block1, and then uniformly erasing all invalid data in the source physical block.
In one possible implementation, as shown in fig. 7C, each physical Page (Page) in each Block in the SLC storage area 1031 includes a data area and a metadata area, and at this time, the target data to be rewritten and the corresponding data type identifier may be stored in the data area and the metadata area, for example, the updated data 1 'and the corresponding data type identifier (identifier 1) are written in the free physical Page0, and the corresponding data type identifier (identifier 1) is written in the corresponding metadata area at the same time, the data 3' is written in the free physical Page1, and the corresponding data type identifier (identifier 3) is written in the corresponding metadata area at the same time.
The location where the data is stored is identified with respect to the data type of the data to be stored, and a metadata area in a physical page where the target data is stored may be stored as shown in fig. 6C or fig. 7C. Optionally, the data type identifiers of all the storage data may also be stored in one or more physical blocks in the storage device 103 in a unified manner, that is, the specific storage location of the data type identifier is related to the decision of the file system run by the host, which is not limited in this embodiment of the present invention. As long as the data type identifier of the stored data can be stored, the subsequent identification of the type of the data is facilitated, so that the function of the storage controller 1033 performing subsequent residence or recovery according to the type of the data is finally realized. Further, once the data type identifier of the data is determined and stored, the data can be circulated between the host 10 and the storage device 103 (host 10 → storage device 103 → host 10 → storage device 103 … …) all the time, that is, after the target data is read next time by the host 10 side, the data type identifier of the data can be read together, and the data type identifier is continuously carried in the write command when the target data is stored in the storage device 103 next time, so that the storage and circulation functions of the "tag" are finally realized.
3. How to recycle or reside data to be recycled when memory space is recycled
1) Which case will trigger the physical Block (Block) in the first storage area to do storage space reclamation
In the present application, whether data is newly written or rewritten, the storage device 103 consumes the free physical Block (Block) in the first storage area 1031, so that the number of remaining free physical blocks (Block) is reduced. When the number of remaining free physical blocks (blocks) is less than a certain number, the data may not be stored in the first storage area 1031. Therefore, more free physical blocks Block can be released for writing of new data by performing a memory space reclamation (GC) operation on a part of physical blocks in the first memory area 1031. The following examples provide several conditions that trigger memory reclamation of physical blocks in the first memory area 1031:
(1) when the host 10 side has data read/write operations and the number of remaining free physical blocks in the first storage area (e.g., SLC storage area) is less than a certain proportion or number, a Garbage Collection (Garbage Collection) operation may be actively initiated by the host 10 side.
(2) When the host 10 side detects that there is no read-write demand (i.e. the load is free) currently, and the number of free physical blocks remaining in the first storage area (e.g. SLC storage area) is less than a certain proportion or number, it actively initiates a request of a garbage collection operation to collect a part of the storage space of the first storage area 1031.
(3) Optionally, the garbage collection operation may be performed only after the host 10 side has data read-write operation, or after the host 10 side detects that there is no read-write requirement currently.
(4) When the memory controller 1033 inside the memory device 103 monitors that the current load of the memory device 103 is idle (i.e. no read command or write command is received), it may actively initiate a request of a garbage collection operation to collect a part of the memory space of the first memory region 1031.
That is to say, the garbage collection may be initiated actively by the host 10 side when a certain condition is satisfied, or may be initiated actively by the storage device 103 side when a certain condition is satisfied, which is not limited in this embodiment of the present invention.
2) After the recovery of the storage space is triggered, how to recover or reside the data
In a possible implementation manner, in the recovery process of the storage space, all valid data in the source physical block to be recovered is moved, and then the whole physical block is erased (erase), and after the erase, the physical block becomes a free physical block. In the embodiment of the present invention, when performing a Garbage Collection (GC) operation on a part of physical blocks (for example, including one or more target data) in the storage device 103, different operations need to be performed on different types of data according to the type of the data. In this application, the data to be stored at least includes a first type and a second type, and therefore, how to perform garbage collection on the first type and the second type of data respectively is described in detail below:
(1) storage space reclamation for a first type of data
Since the first type of data has a high requirement on storage performance, the type of data is continuously resident in the first storage area 1031, but since there may be other second type of data in a physical Block in which the first type of data is located, and recovery (i.e., erasure) for a certain physical Block is in units of blocks (blocks), the first type of data in the physical Block needs to be moved to other physical blocks in the first storage area 1031.
(2) Memory space reclamation for second type data
Since the second type of data has a low requirement on storage performance, the type of data needs to be recycled (or moved) to the second storage area 1032 with relatively weak storage performance for storage, and more physical blocks in the first storage area are freed up for use by the first type of data with a higher requirement on storage performance.
That is, for the first type of data and the second type of data, in the process of recovering the storage space (e.g., garbage collection operation), the data to be recovered (the first type of data and the second type of data) is directed to different destination physical blocks from the same source physical block through the tag attached to the data (i.e., the data type identifier), so as to implement the shunting operation of garbage collection.
As shown in fig. 8A-8C, fig. 8A-8C are schematic diagrams of data reclamation in some garbage reclamation processes according to the embodiment of the present invention, for example, it is assumed in fig. 8A that a source physical Block to be reclaimed includes Block1 in a static SLC storage area, at this time, since the Block1 includes invalid data, and data of a first type (for example, Hot data Hot) and data of a second type (for example, cold data cloud), corresponding migrated destination physical blocks are Block S-1 in the dynamic SLC storage area 1031 and Block5 in the MLC/TLC storage area 1032. Specifically, as shown in fig. 8B, the first type of data (e.g., hot data), i.e., data 4 in Page3 and data N in Page N-1, are still resident in the SLC storage area 1031, but since the physical Block1 needs to be reclaimed (i.e., erased completely), valid data 4 and valid data N need to be moved to other physical blocks in the SLC storage area 1031, for example, to pages 0 and 1 in Block S-2 in the dynamic SLC area. It should be understood that the shifting to other physical blocks in the static SLC area is only shown by way of example, and the specific destination physical block to be shifted is not limited, as long as any free physical block (partially free or fully free) in the SLC area that does not need to be garbage collected currently is shifted. For the second type of data (e.g., cold data), i.e., data 2 in Page1, it needs to be recovered to a physical Block in the MLC/TLC storage area 1032, for example, Block5, and after all the valid numbers are moved, all the data in the source physical Block1 may be set as invalid, and at this time, all the invalid data in the Block (including the originally invalid data and the data set as invalid after the moving) may be erased, so that a free physical Block, i.e., Block1 in the static SLC area, is released.
Further optionally, as shown in fig. 8C, each physical Page (Page) in each Block includes a data area and a metadata area, at this time, the recycled data itself and the corresponding data type identifier may be recycled to the data area and the metadata area, for example, data 4 and data N in the static SLC storage area are moved to physical pages Page0 and Page1 in the dynamic SLC storage area, and at the same time, the corresponding data type identifier (identifier 4 and identifier N) is moved to the corresponding metadata area, and data 2 is moved to Page0 of Block5 in the MLC/TLC storage area 1032, and at the same time, the corresponding data type identifier (identifier 2) is moved to the corresponding metadata area.
It should be noted that the physical block for initially storing the first type data in the SLC Buffer may be a physical block stored in a static SLC Buffer, or a physical block stored in a dynamic SLC Buffer. The source physical block selected by garbage collection may be a physical block of a static SLC Buffer or a physical block of a dynamic SLC Buffer. That is, during the SLC to SLC move or relocation (relocation), the SLC blocks are not necessarily limited to static or dynamic ones as long as the target blocks are SLC blocks. In summary, it is not specifically limited whether the target data is initially stored in the dynamic SLC area or the static SLC area, and it is not specifically limited whether the target data is moved between blocks in the static and static SLC storage areas, between blocks in the dynamic and dynamic SLC storage areas, or between blocks in the static and dynamic SLC storage areas when the target data is subsequently moved, as long as the target data of the first type is moved between blocks in the SLC storage area.
Based on the above descriptions of garbage collection for data of the first type and the second type, there may be following collection cases for a certain SLC physical block in the SLC storage area:
(1) the SLC physical block has only the first type of data therein
Since only valid data of the first type (for example, hot data) exists in the physical block, and the data of the first type needs to continue to reside in the first storage area, at this time, all hot data in the physical block may not be recycled, i.e., not processed; alternatively, all the hot data on the physical block may be moved to another physical block in the first storage area, for example, from a physical block in the static SLC storage area to a physical block in the dynamic SLC storage area. That is, when only valid hot data exists in a certain physical block, the physical block may be entirely transferred to another physical block in the first storage area, or a recovery operation may not be performed on the physical block, that is, data transfer is not performed.
(2) The SLC physical block has only the first type of data and invalid data
Since the physical block has valid first type data (for example, hot data) and invalid data, and the space can be released only by performing an erase operation on the invalid data, and the erase operation must be performed in units of blocks, the first type data on the physical block needs to be moved to another physical block in the first storage area that does not need to be recovered, and then the invalid data in the physical block (only the invalid data remains at this time) needs to be erased, so that the space on the physical block can be released, and a free physical block can be obtained.
(3) The SLC physical block having only the second type of data or only the second type of data and invalid data
For the second type of data (for example, cold data), the cold data needs to be moved from the physical blocks in the first storage area 1031 to the physical blocks in the second storage area 1032, so after all the cold data is moved to the second storage area 1032 at this time, all the data in the source physical blocks in the first storage area 1031 may be set to be invalid, and then all the invalid data is erased, so that the free physical blocks can be released.
When the physical block has both cold data and invalid data, the same reasoning applies, that is, after the cold data is moved, all the data left in the source physical block are invalid data (including data which is originally invalid and is set as invalid after the moving), so that all the invalid data can be erased, and the free physical block can be released.
(4) The SLC physical block has both the first type of data and the second type of data or the first type of data, the second type of data, and invalid data.
When a physical Block contains both first type data and second type data (for example, hot data and cold data, respectively), since erasure is in Block (Block) units in NAND Flash, it is impossible to move only cold data to the second storage area and retain hot data in the original physical Block. Therefore, it is necessary to move hot data to another physical block in the first storage area 1031 and move cold data to a physical block in the second storage area 1032.
It should be noted that the process of moving data is actually rewriting data in a new physical block and setting the data in the source physical block to be invalid.
In a possible implementation manner, assuming that the first storage area is a storage-level memory SCM medium, and the second storage area is another medium with relatively poor storage performance than the SCM, for example, the first storage area is a 3D stacked phase change memory X3D (3D-Xpoint), and the second storage area is a TLC storage area, according to the storage characteristics of X3D, garbage collection for the first storage area only needs to be updated "on site", that is, when performing garbage collection operation, data of the first type resides in one or more physical pages in the first storage area, and does not need to be moved, and when performing garbage collection operation for data of the second type, data needs to be moved. That is, the first type of data is stored in the original Block, and only the second type of data needs to be moved from the physical Block of X3D to the TLC physical Block. I.e., SCM is faster than NAND, than SLC, which is a "displaced update".
4. Host side Host reads data in storage device specifically
Based on the data after the split-stream storage, when the host side reads the data, the host controller 102 directly reads the data from the SLC storage area where the data is currently located into the internal memory 101, or directly reads the data from the MLC/TLC area where the data is currently located into the internal memory 101. That is, during the process of reading data by the host 10, there is no need to perform identification or classification of data type identification, i.e., the cold data stored in the TLC or MLC memory area does not need to be further read into the static SLC memory area. In a possible implementation manner, the host 10 still stores the data type identifier of the read data after reading the data, so that when a write command is issued for the data next time, the data type identifier may be directly carried in the write command without re-identification, where the data type identifier may be stored in file system Metadata (META), and the metadata of the file system may be flushed to an external memory (i.e., the storage device 103) for long-term storage, or imported to the internal memory 101 for use when the host runs.
Compared with the prior art, when data is written into the solid-state storage device, the data is firstly uniformly written into the SLC with higher performance, and when garbage recovery operation is required, the data is then uniformly written into the TLC or MLC with poorer performance; in the embodiment of the invention, data is firstly and uniformly written into an SLC with higher performance, when garbage collection operation is required, data of a first type (such as hot data) is continuously stored in the SLC by writing data of a second type (such as cold data) into TLC or MLC with poorer performance (the process does not represent that the data is not completely fixed, but is possibly moved in different blocks in an SLC storage area, and the SLC storage area belongs to a remote updating mechanism). It should be noted that, compared to MLC/TLC, SLC has higher read performance and write performance, i.e. faster read/write speed, longer endurance and data retention, but higher cost. Therefore, in the present application, the function of the second storage area may be implemented by using a lower-cost MLC/TLC, and the function of the first storage area is implemented by converting a part of MLC/TLC into an SLC, because the performance of the first storage area is superior to that of the second storage area, data of the first type having a higher requirement on storage performance may be stored in the first storage area from beginning to end to ensure its read-write performance, and data of the second type having a lower requirement on storage performance may be stored in the first storage area to ensure initial write performance, but may be further transferred and stored in the second storage area having a larger capacity and a lower cost through a garbage collection mechanism, so that the cost may be reduced on the premise that the overall storage performance of the data is higher.
Of course, during the above-described transition from TLC or MLC to dynamic SLC. The memory space is reduced to one third if switching from TLC to SLC and to one half if switching from MLC to SLC. Assuming 256G TLC, 256/3G if it is converted to SLC for use, i.e. the storage size becomes one third of the original; if 256G MLC is converted to SLC, 256/2G is reached, i.e. the size of the storage space is reduced to one half. The above conversion process may be performed by a controller in the solid-state storage device.
It should be noted that, although in the above-mentioned embodiments of some inventions, the first storage area is SLC memory, and the second storage area is MLC/TLC memory as an example, according to the data storage method disclosed in this application, the first storage area and the second storage area may also be other storage media or other types of memory, which are not listed here.
Fig. 9A shows a flow of a data storage method according to an embodiment of the present invention, where the method is applied to an electronic device, please refer to fig. 9B, where fig. 9B is a schematic structural diagram of another electronic device according to an embodiment of the present invention, an electronic device 20 may include a processor 100, an internal memory 101, and an external memory 103, the internal memory 101 includes a normal partition 1011 and a SWAP partition 1012, where the normal partition 1011 is a partition that normally provides a memory space in the internal memory 101, and the SWAP partition 1012 is used for storing a part of data in a part of the normal partition 1011 after being compressed into the SWAP partition 1012 when the space of the normal partition 1011 is not enough; the external memory 103 includes a first storage region 1031 and a second storage region 1032, and the storage performance of the first storage region 1031 is superior to that of the second storage region 1032. For the description of the internal memory 101 and the external memory 103, reference may be made to the description of the host 10 and the storage device 103 in fig. 2A to 8C, where the external memory 103 is identical to the storage device 103, and is not described herein again. The method flow mainly describes the method steps at the electronic device side, and the method can comprise:
s101: the electronic equipment runs N application programs, and running data of the N application programs is stored in the internal memory; the N application programs comprise a first application program, the first application program is an application program operated in a foreground, the first application program occupies partial space of the common partition, and N is a positive integer.
Specifically, assuming that a plurality of applications are currently running on the electronic device (for example, a user opens a pan, a WeChat, a QQ, a video, a reading, etc. on a mobile phone at the same time), the running data of the applications are currently loaded into a common partition in the internal memory 101, so that the processor 100 of the electronic device 10 can run any one of the above N applications in the foreground at any time. Assume that a current user is running a first application, such as WeChat, in the foreground of the electronic device, i.e., is chatting through the WeChat application.
S102: in response to a launch operation of a second application, the electronic device determines a remaining space of the normal partition and a remaining space of the SWAP partition.
Specifically, for example, when the user clicks the launch icon of the second application, such as clicking the icon of the video application, the electronic device 20 needs to determine the current remaining space of the normal partition and the remaining space of the SWAP partition, so as to provide enough space for the second application to store its running data in the normal partition 1011 of the internal memory 101, so that it can run normally in the processor 100. It should be noted that the operation of starting the second application is not necessarily to click the start icon of the second application, but may be to click an associated button, a switch button, a trigger button, and the like in another application, or to trigger the system background, and the like, and is not limited in particular here.
S103: and if the residual space of the common partition and the residual space of the SWAP partition are insufficient, determining the data of the SWAP partition as the data of the first type, storing the data into the first storage area, and emptying the SWAP partition.
S104: compressing the running data of M application programs in the N application programs, storing the compressed running data to the SWAP partition, and releasing the common partition occupied by the M application programs; wherein the M applications include the first application.
S105: foreground running the second application; and the second application program occupies part or all of the common partition occupied by the released M application programs.
Specifically, the determination in step S102 may include the following cases:
case 1: the remaining space of the normal partition 1011 is enough, and the remaining space of the SWAP partition 1012 is enough or not enough, so that the running data of the second application can be normally loaded into the normal partition 1011, i.e. the second application can normally run in this case 1.
Case 2: if the remaining space of the normal partition 1011 is not enough but the remaining space of the SWAP partition 1012 is enough, the running data of a part of the application programs in the normal partition 1011 can be compressed and stored into the SWAP partition 1012, and the occupied space of the normal partition 1011 is released, so that the space of the normal partition 1011 can be partially made available for the second application program to run normally.
Case 3: when the remaining space of the normal partition 1011 and the remaining space of the SWAP partition 1012 are not enough, in the embodiment of the present invention, the SWAP partition 1012 is emptied, that is, the SWAP partition is released, by determining the data of the SWAP partition as the data of the first type, and storing the data of the SWAP partition into the first storage area 1031; further, the operation data of M applications in the N applications is compressed, the compressed operation data is stored in the SWAP partition 1012, and the common partition 1011 occupied by the M applications is released, at this time, the operation data of the second application may be loaded into the released common partition 1011 from the external memory 103, that is, the second application may operate normally. Moreover, at this time, since the data of the SWAP partition is stored in the first storage area 1031 as the first type of data (i.e. is not subsequently recovered to the second storage area 1032), when the running data of any application program in the data of the SWAP partition needs to be recovered, the running data can be quickly recovered from the first storage area 1031 to the internal memory 101 (for example, read out to the SWAP partition 1012 first and recovered to the normal partition 1011) based on the superior storage performance of the first storage area 1031, thereby achieving the effect of effectively expanding the SWAP partition.
S106: and responding to the starting operation of the first application program, and reading the running data of the first application program from the SWAP partition.
S107: decompressing the running data of the first application program, and running the first application program in a foreground.
Specifically, when the user wants to re-open the first application used before, the data of the first application is already compressed into the SWAP partition in step S104, and therefore needs to be decompressed from the SWAP partition into the normal partition 1011 to be normally operated. And can operate in the foreground according to the use requirements of users. It should be noted that the operation of starting the first application is not necessarily to click the start icon of the first application, but may be to click an associated button, a switch button, a trigger button, and the like in another application, or to trigger the system background, and the like, and is not limited in particular here.
It should be noted that, since the data of the SWAP partition is all data that is reserved when the application runs, for example, the data includes context data and the like required when the application runs, after the data of the SWAP partition is restored to the normal partition, the corresponding application may return to the interface that was originally killed, that is, for the user perception, the application is not really killed (ended), but is suspended, that is, when the user or the system triggers to start the first application again, the user interface that was used by the user last time may still be returned.
In the embodiment of the present invention, when the memory space of the electronic device is insufficient, including the insufficient space of the SWAP partition in the memory, the data of the SWAP partition may be determined as the data of the first type in the embodiment of the present invention, and the data of the first type is stored in the first storage area 1031 in the external memory 103, so that the space of the SWAP partition in the internal memory 101 may be released, and therefore, part of the data of the normal partition in the internal memory 101 may be further compressed to the SWAP partition and the space of the normal partition may be released again to meet the memory space requirement of more applications. Based on the above, the application program that may need to be killed may continue to remain in the first storage area 1031 with a higher storage speed without being killed, thereby achieving the effect of expanding the SWAP partition. The keep-alive rate of the background application program is improved when the memory space is insufficient, namely under the condition of the same memory space size, the electronic device provided by the embodiment of the invention can enable more application programs to keep the running data (including the context state) of the application programs, so that the purpose of not being killed is realized, and when a user needs to call out the application programs from the background again, the application programs can return to the suspended state, so that the user experience is greatly improved.
In one possible implementation manner, before the reading of the running data of the first application program from the SWAP partition, the method further includes: searching the running data of the first application program in the first storage area; and reading the running data containing the first application program in the first storage area into the SWAP partition. In some possible cases, for example, when the second application is running in the foreground, the user runs another application, so that the remaining space of the normal partition 1011 and the SWAP partition 1012 is still insufficient, and then the process of determining the data of the SWAP partition as the first type of data, storing the data into the first storage area, and emptying the SWAP partition needs to be performed again; that is, the compressed operation data of the M applications in the N applications is transferred from the SWAP partition 1012 to the first memory area 1031, and the SWAP partition 1012 is emptied. Since the compressed running data of the M applications includes the running data compressed by the first application, if the user needs to restore the first application again, the running data compressed by the first application is searched in the first storage area 1031 and is reloaded into the SWAP partition 1012, and is restored from the SWAP partition 1012 to the normal partition 1011, so as to facilitate normal operation. If the remaining space of the SWAP partition is not enough, the data in the SWAP partition 1012 needs to be continuously transferred to the first memory area 1031 to make room for the data recovered from the first memory area 1031 or the data compressed from the normal partition 1011.
In one possible implementation, the method further includes: and selecting M application programs with high priority levels from the N application programs to determine the M application programs, and releasing the space of the common partition occupied by the L application programs with low priority levels in the N application programs. In the embodiment of the present invention, for some applications with low user usage frequency or low priority, the checking and killing may be performed when the memory space (e.g., the remaining space of the normal partition) is not enough, so as to directly release the space occupied by the applications in the normal partition, that is, the space occupied by the applications in the SWAP partition 1012 is also not allowed to be occupied, and more spaces of the normal partition and the SWAP partition are left for the applications with high priority or the applications with high user usage frequency. The priority of the application program may be determined by the electronic device by monitoring the use frequency of the user, or may be manually set by the user, for example, setting the application program that the user wants to keep alive to be high in priority, and setting other common application programs to be low in priority. For example, a user may set WeChat to a high priority if it is used frequently, and a mailbox application that is less frequently used by the user may be set to a low priority.
In a possible implementation manner, the determining the data of the SWAP partition as the first type of data, and storing the data into the first storage area includes: generating a write command for data of the SWAP partition, the write command including a data type identification of a first type of data of the SWAP partition; and storing the data of the SWAP partition and the data type identifier of the first type into the first storage area according to the write command. In the embodiment of the present invention, after the data of the SWAP partition is determined as the first type of data, the data type identifier of the data of the SWAP partition is carried in the write command of the data of the SWAP partition, and the data of the SWAP partition is written while the corresponding data type identifier is stored, so that when the storage space (for example, the physical block where the data of the SWAP partition is located) occupied by the data of the SWAP partition is to be retrieved subsequently, it can be determined according to the data type identifier that the data of the SWAP partition can continuously reside in the first storage area with better storage performance, rather than being retrieved as the second type of data to the second storage area with relatively poorer storage performance.
In one possible implementation, the method further includes: if the storage space of the first storage area meets the recovery condition, the data of the first type is kept in the first storage area, and the data of the second type is recovered to the second storage area; wherein the first type of data has a higher storage performance requirement than the second type of data. According to the embodiment of the invention, various types of data can be uniformly written into the first storage area with better storage performance (such as random reading/writing performance) so as to improve the writing performance of initial storage of various types of data; because the data type identifier of the data is carried in the write command of the data, and the data type identifier corresponding to the data is stored while the data is written, when the data is subsequently recovered with respect to the storage space (for example, the physical block in which the data is located) occupied by the data, whether the data continuously resides in the first storage area with better storage performance or is recovered to the second storage area with relatively poorer storage performance can be determined according to the data type identifier.
In one possible implementation manner, the storing the data of the SWAP partition and the data type identifier of the first type into the first storage area includes: storing the data of the SWAP partition and the data type identification of the first type into a first storage Block in the first storage area; if the storage space of the first storage area meets the recycling condition, the step of retaining the first type of data in the first storage area comprises: and if the storage space of the first storage area meets the recovery condition, moving the data of the SWAP partition and the data type identifier of the first type from a first storage Block in the first storage area to a second Block in the first storage area. In the embodiment of the present invention, when the storage space occupied by the data of the SWAP partition in the first storage area is recovered, according to the characteristics of some storage media, the data of the SWAP partition may need to be rewritten into other physical blocks in the first storage area, so as to vacate the storage space occupied by the data of the SWAP partition. For example, in the SLC, if the recovery memory space is in physical block units (i.e., the erase is in block units), when the memory space occupied by the SWAP partition is recovered, the physical block in which the SWAP partition is located is actually recovered in its entirety, so that all valid data in the physical block in which the SWAP partition is located needs to be moved, specifically, the memory space of the entire physical block is recovered by moving the first type of SWAP partition into another physical block in the first memory area and moving the second type of other data into the second memory area.
It should be noted that, for a specific flow of the data storage method described in the embodiment of the present invention, reference may be made to the related description in the embodiment of the present invention described in fig. 2A to fig. 8C, and details are not repeated here.
The data storage method in the present application is further described below with the electronic device 20 as a smart phone and in combination with an actual application scenario.
Referring to fig. 9C-9E, fig. 9C-9E are some user interfaces for using applications provided by embodiments of the present inventionSchematic of the face. For example, a user logs in to an application program when starting up: (
Figure BDA00024769394900003414
Shopping applications, game applications, entertainment applications, etc.), and it is assumed how the host 10 and the storage device 103 interact later, specifically based on the data storage method of the present application, due to exiting the application program or after the user suspends the application. Wherein,
1. when a user wants to run a social application installed on the electronic device 20, such as
Figure BDA00024769394900003415
Application, please see user interface 91, when the user can click through an input device of electronic device 20, such as display screen 106
Figure BDA00024769394900003416
Icon 901.
2. A sensor in the display screen 106 of the electronic device 20 sends a click command to the processor 100.
3. After the processor 100 receives the instruction, it will be controlled by the host controller 102
Figure BDA00024769394900003417
Instructions and data related to the application program are loaded from the external memory (the first storage area 1031 in the external memory 103) into the internal memory 101 (such as the ordinary partition 1011 of the internal memory 101 in the host) (without going through the processor, the instructions and data are loaded directly from the external memory into the internal memory).
4、
Figure BDA00024769394900003418
After the relevant instructions and data of the application program are loaded into the internal memory 101, the processor 100 starts to run
Figure BDA00024769394900003419
An application program.
5、
Figure BDA00024769394900003420
After the application is executed in the processor 100, the processor 100 displays the operation result through an output device (e.g., the display screen 106), that is, displays a part of data in the memory to the display screen 106, where the part can be completed by the cooperation of the GPU and the CPU. For example, referring to user interface 92, the user is prompted to log in by filling in an account and password via account entry box 902 and password entry box 903
Figure BDA00024769394900003421
The application interface is a user interface 93. Assuming that the user clicks on the chat window with the user Arvin, the chat interface shown in user interface 94 is entered.
6. Referring to the user interface 95 shown in fig. 9D, it is assumed that the user needs to perform a photographing operation at this time, the user clicks the camera button 906 to take a photograph, enters the user interface 96, and clicks the photographing button 907 to take a photograph, so as to obtain a photographed picture shown by the user interface 97. At this time, the picture may be temporarily saved in the normal partition 1011 of the internal memory 101, and the user may edit the picture (e.g., add an emoticon, add a text, mosaic process, etc.) when the photographing interface is not exited. When the user clicks the send button 908, the picture needs to be saved and sent, and at this time, the picture is saved from the internal memory 103 to the external memory 103. That is, after the user performs the save or send 908 operation, the processor 100 writes the data corresponding to the picture from the memory to the external memory. Specifically, based on the description in FIG. 3A, assume that the user set up
Figure BDA00024769394900003424
Is "fast mode", and thus is relevant to
Figure BDA00024769394900003423
Part or all of the data of the application program is recognized by the host 10 side as data of the first type, and at this time, the processor 100 transmits the picture to the external memory 103 through the host controller 102 to be storedThe data type identification of the first type needs to be carried in the write command for the picture. In this way, the external memory 103 may store the picture and the corresponding first type data type identifier in the first storage area 1031 in the external memory 103, and when garbage collection is performed on the Block where the picture is located, the picture may continue to reside in the first storage area 1031 by the first type data type identifier, and when it needs to be read out from the first storage area 1031 again, the picture may be quickly read out.
7. Referring to the user interface 98 and the user interface 99 shown in fig. 9E, assume that the user suddenly receives a call from marie, a colleague, calls by clicking the answer button 911, and enters the user interface 100 for answering the call while the user is on the user interface 98. After talking to mary, a period of time, the user ends the call by clicking on hang-up button 912. Assuming that many applications are started in the background of the electronic device 20 during this period (for example, the remaining space of the normal partition 1011 and the SWAP partition 1012 included in the memory 101 is not enough), if in the prior art, the user may be caused to receive a call before the application is started
Figure BDA00024769394900003426
The interface of the application, i.e., user interface 98, is kicked out of the memory space, i.e., forcibly closed by the background. I.e., user interface 100, is not able to quickly or directly return to user interface 98 after the call is completed, because at this point in time
Figure BDA00024769394900003425
The application program is forced to be closed by the system background due to the memory shortage. However, it is assumed that the electronic device 20 applies the data storage method in fig. 9A described above in this application, that is, at this time, the data in the Swap partition is transferred to the first storage area 1031, so that the Swap partition 1012 is emptied and will be used
Figure BDA00024769394900003422
The running data of the application program is compressed from the ordinary partition 1011 to the Swap partition 1012, and thenAfter the user hangs up the phone, the system
Figure BDA0002476939490000357
The application's operating data may be quickly returned from the Swap partition 1012 to the normal partition so that the user may return to the user interface 98 quickly or directly. Further, in this process, assuming the space of the Swap partition 1011 is further strained, it needs to include the compressed one
Figure BDA0002476939490000358
When the data of the Swap partition including the running data of the application program is transferred to the first storage area 1031, since the data saved in the Swap partition is determined as the first type of data by the host side (and is not recycled to the second storage area 1032 later), after the user finishes the phone call,
Figure BDA00024769394900003511
the operation data of the application program can still be quickly restored from the first storage area 1031 with better read-write performance to the internal memory 101, so that the application program has faster read-out performance. Therefore, after the data storage method in the present application is applied, the user can quickly return to the user interface 101 after the user interface 100 hangs up the phone call, that is, the user interface 98 before answering the phone call.
8. When the user clicks
Figure BDA00024769394900003512
The above actions are repeated when other functions or contents of the application are applied. That is, the processor 100 fetches from the memory according to the instruction issued by the user
Figure BDA0002476939490000359
The relevant data of the application and the calculation result are stored in the memory temporarily, when the processor 100 receives the instruction that the user needs to store the data in the external memory 103 for a long time, the processor 100 controls the reading of the part of data from the memory and the writing of the part of data into the external memory 103 through the host controller 102.
9. When the user clicks to quit
Figure BDA00024769394900003510
When the application program is used, the processor 100 sends an instruction to clear (flush) data in the memory (the internal memory 101), and stores the history data or the cache data in the first storage area 1031 of the external memory 103, and subsequently, the data type identifier of the first type data can be used to reside in the first storage area 1031 with better performance for a long time, so that the use experience of the user is improved.
Fig. 10 shows a general flow of a data storage method provided by an embodiment of the present invention, which is applied to a host and a storage device, where the storage device is a non-volatile memory and includes at least a first storage area and a second storage area, and the storage performance of the first storage area is better than that of the second storage area; for the description of the host and the storage device, reference may be made to the description of the relevant apparatuses or devices in fig. 2A to 8C, which is not described herein again. The method flow mainly describes the method steps of interaction between the host side and the storage device side, and the method can comprise the following steps:
s201: the host determines the data type of the target data to be written to the storage device.
S202: generating a write command aiming at the target data by the host, wherein the write command comprises a data type identifier of the target data; the data type identifier is used for identifying the first type or the second type.
S203: the host sends the write command to the storage device, wherein the write command is used for indicating the storage device to store the target data and the data type identifier; the storage device receives a write command aiming at target data sent by a host side, wherein the write command comprises a data type identifier of the target data.
S204: and the storage equipment writes the target data and the data type identification into the first storage area according to the write command.
S205: and if the storage space occupied by the target data needs to be recycled, the storage equipment identifies the data type of the target data according to the data type identifier, wherein the data type comprises a first type and a second data type.
S206A: if the storage device determines that the target data is of the first type, the target data is reserved in the first storage area.
S206B: if the storage device determines that the target data is of a second type, the target data is moved to the second storage area; wherein the first type of data has a higher storage performance requirement than the second type of data.
S207: the host sends a read command aiming at the target data to the storage device; and the storage equipment receives a read command aiming at the target data sent by the host side.
S208A: if the target data is of the first type, the storage device controls the target data to be read out from the first storage area; the host reads the target data and the data type identification from the first storage area;
S208B: and if the target data is of the second type, the storage equipment controls the target data to be read out from the second storage area. The host reads the target data and the data type identification from the second storage area.
S209: and the host stores the read target data and the data type identifier into the internal memory, wherein the host comprises the internal memory, and the internal memory is a volatile memory.
In a possible implementation manner, if it is determined that the target data is of the first type, the retaining the target data in the first storage area includes: and if the target data is determined to be the first type, keeping the target data and the data type identification in the first storage area.
In a possible implementation manner, the storage device is one or more of a universal flash memory UFS, an embedded multimedia card eMMC, a universal flash memory multi-chip package upmcp memory, and an embedded multimedia card multi-chip package eMCP memory; the first storage area comprises one or more of a single-layer cell SLC storage area, a Fast NAND memory, a Phase Change Memory (PCM) and a 3D stacked phase change memory (X3D), and the second storage area comprises one or more of a multi-layer cell (MLC) storage area, a three-layer cell (TLC) storage area, a four-layer cell (QLC) storage area and a five-layer cell (PLC) storage area.
In one possible implementation manner, the writing the target data and the data type identifier into the first storage area includes: writing the target data and the data type identifier into a first storage Block in the first storage area; if the target data is determined to be the first type, the step of retaining the target data in the first storage area includes: and if the target data is determined to be the first type, moving the target data and the data type identifier from a first Block in the first storage area to a second Block in the first storage area.
In one possible implementation, the first memory region comprises an SLC memory region; the SLC storage area comprises a static SLC storage area and a dynamic SLC storage area; the first Block is a Block in the static SLC storage area, and the second Block is a Block in the dynamic SLC storage area; or the first Block is a Block in the dynamic SLC memory region, and the second Block is a Block in the static SLC memory region, or both the first Block and the second Block are blocks in the static SLC memory region; or both the first Block and the second Block are blocks in the extended dynamic SLC memory region.
In a possible implementation manner, the moving the target data to the second storage area if it is determined that the type of the target data is the second type includes: and if the target data type is determined to be a second type, rewriting the target data and the data type identifier into the second storage area, and setting the target data in the first storage area as invalid.
In one possible implementation, the storage performance includes one or more of a random read performance, a random write performance, and a storage lifetime.
In one possible implementation, the first type of data includes one or more of file system metadata, a high frequency access database, SWAP area SWAP data. Optionally, the host side determines whether the target data is any one of file system metadata, a high-frequency access database, or SWAP data; if yes, determining the target data as the first type of data; if not, the target data is judged to be the second type of data, and the storage performance requirement of the first type of data is higher than that of the second type of data.
It should be noted that, for a specific flow of the data storage method described in the embodiment of the present invention, reference may be made to the related description in the embodiment of the present invention described in fig. 2A to fig. 9E, and details are not repeated here.
An embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium may store a program, and when the program is executed by a host or a storage device, the program implements part or all of the steps of any one of the data storage methods described in the above method embodiments.
Embodiments of the present invention also provide a computer program, where the computer program includes instructions, and when the computer program is executed by a host or a storage device, the host or the storage device may execute some or all of the steps of any data storage method.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the above-described division of the units is only one type of division of logical functions, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be an electric or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit may be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a separate product. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a storage medium, and including several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, and may specifically be a processor in the computer device) to execute all or part of the steps of the above-mentioned method of the embodiments of the present application. The storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a magnetic disk, an optical disk, a Read-only memory (ROM) or a Random Access Memory (RAM).
The above embodiments are only used for illustrating the technical solutions 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 solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (38)

1. The data storage method is applied to a storage device, wherein the storage device is a nonvolatile memory and at least comprises a first storage area and a second storage area, and the storage performance of the first storage area is better than that of the second storage area; the method comprises the following steps:
receiving a write command for target data, wherein the write command comprises a data type identification of the target data;
writing the target data and the data type identification into the first storage area according to the write command;
if the storage space occupied by the target data needs to be recovered, identifying the data type of the target data according to the data type identifier; the data types comprise a first type and a second data type;
if the target data is determined to be the first type, the target data is reserved in the first storage area; if the target data is determined to be of the second type, moving the target data to the second storage area; wherein the first type of data has a higher storage performance requirement than the second type of data.
2. The method of claim 1, wherein the method further comprises:
receiving a read command for the target data;
if the target data is of the first type, controlling the target data to be read out from the first storage area;
and if the target data is of the second type, controlling the target data to be read out from the second storage area.
3. The method of claim 1 or 2, wherein the storage device is one or more of a universal flash memory UFS, an embedded multimedia card eMMC, a universal flash memory multi-chip package upmcp memory, an embedded multimedia card multi-chip package eMCP memory; the first storage area comprises one or more of a single-layer cell SLC storage area, a Fast NAND memory, a Phase Change Memory (PCM) and a 3D stacked phase change memory (X3D), and the second storage area comprises one or more of a multi-layer cell (MLC) storage area, a three-layer cell (TLC) storage area, a four-layer cell (QLC) storage area and a five-layer cell (PLC) storage area.
4. The method of claim 3, wherein said writing the target data and the data type identification to the first storage area comprises: writing the target data and the data type identifier into a first storage Block in the first storage area;
if the target data is determined to be the first type, the step of retaining the target data in the first storage area includes:
and if the target data is determined to be the first type, moving the target data and the data type identifier from a first Block in the first storage area to a second Block in the first storage area.
5. The method of claim 4, wherein the first memory region comprises an SLC memory region; the SLC storage area comprises a static SLC storage area and a dynamic SLC storage area;
the first Block is a Block in the static SLC storage area, and the second Block is a Block in the dynamic SLC storage area; or,
the first Block is a Block in the dynamic SLC memory region, the second Block is a Block in the static SLC memory region, or,
the first Block and the second Block are both blocks in the static SLC storage area; or,
the first Block and the second Block are both blocks in the extended dynamic SLC memory region.
6. The method of any of claims 1-5, wherein the moving the target data to the second storage area if it is determined that the target data is of the second type comprises:
and if the target data type is determined to be the second type, rewriting the target data and the data type identifier into the second storage area, and setting the target data in the first storage area as invalid.
7. The method of any of claims 1-6, wherein the storage performance comprises one or more of random-read performance, random-write performance, and storage lifetime.
8. The method of any of claims 1-7, wherein the first type of data comprises one or more of file system metadata, a high frequency access database, SWAP data.
9. A data storage method, applied to a host, the method comprising:
determining the data type of target data to be written into the storage equipment; the data type comprises a first type or a second type;
generating a write command for the target data, the write command including a data type identification of the target data; the data type identification is used for identifying the first type or the second type;
and sending the write command to the storage device, wherein the write command is used for indicating the storage device to store the target data and the data type identifier.
10. The method of claim 9, wherein the method further comprises:
judging whether the target data is any one of file system metadata, a high-frequency access database or SWAP data of an exchange area;
if yes, determining the target data as the first type of data;
if not, the target data is judged to be the second type of data, and the storage performance requirement of the first type of data is higher than that of the second type of data.
11. The method of claim 9 or 10, wherein the method further comprises:
sending a read command for the target data to the storage device;
if the target data is the first type, reading the target data and the data type identifier from the first storage area;
and if the target data is of the second type, reading the target data and the data type identifier from the second storage area, wherein the storage performance requirement of the first type of data is higher than that of the second type of data.
12. The method of claim 11, wherein the host further comprises an internal memory, the internal memory being a volatile memory;
the method further comprises the following steps: and storing the read target data and the data type identification into the internal memory.
13. A storage device, being a non-volatile memory, comprising: the solid-state storage system comprises a storage controller and a solid-state storage array coupled with the storage controller, wherein the solid-state storage array at least comprises a first storage area and a second storage area, and the storage performance of the first storage area is better than that of the second storage area; wherein,
the storage controller is configured to:
receiving a write command for target data, wherein the write command comprises a data type identification of the target data;
writing the target data and the data type identification into the first storage area according to the write command;
if the storage space occupied by the target data needs to be recovered, identifying the data type of the target data according to the data type identifier; the data types comprise a first type and a second data type;
if the target data is determined to be the first type, the target data is reserved in the first storage area; if the target data is determined to be of the second type, moving the target data to the second storage area; wherein the first type of data has a higher storage performance requirement than the second type of data.
14. The storage device of claim 13, wherein the storage controller is further to:
receiving a read command for the target data;
if the target data is of the first type, controlling the target data to be read out from the first storage area;
and if the target data is of the second type, controlling the target data to be read out from the second storage area.
15. The memory device of claim 13 or 14, wherein the memory device is one or more of a universal flash memory UFS, an embedded multimedia card eMMC, a universal flash memory multi-chip package upmcp memory, an embedded multimedia card multi-chip package eMCP memory; the first storage area comprises one or more of a single-layer cell SLC storage area, a Fast NAND memory, a Phase Change Memory (PCM) and a 3D stacked phase change memory (X3D), and the second storage area comprises one or more of a multi-layer cell (MLC) storage area, a three-layer cell (TLC) storage area, a four-layer cell (QLC) storage area and a five-layer cell (PLC) storage area.
16. The storage device of claim 15, wherein the storage controller is specifically configured to:
writing the target data and the data type identifier into a first storage Block in the first storage area;
and if the target data is determined to be the first type, moving the target data and the data type identifier from a first Block in the first storage area to a second Block in the first storage area.
17. The storage device of claim 16, wherein the first storage region comprises an SLC storage region; the SLC storage area comprises a static SLC storage area and a dynamic SLC storage area;
the first Block is a Block in the static SLC storage area, and the second Block is a Block in the dynamic SLC storage area; or,
the first Block is a Block in the dynamic SLC memory region, the second Block is a Block in the static SLC memory region, or,
the first Block and the second Block are both blocks in the static SLC storage area; or,
the first Block and the second Block are both blocks in the extended dynamic SLC memory region.
18. The storage device of any of claims 13-17, wherein the storage controller is specifically configured to:
and if the target data type is determined to be the second type, rewriting the target data and the data type identifier into the second storage area, and setting the target data in the first storage area as invalid.
19. The storage device of any of claims 13-18, wherein the storage performance comprises one or more of random-read performance, random-write performance, and storage lifetime.
20. The storage device of any of claims 13-19, wherein the first type of data comprises one or more of file system metadata, a high frequency access database, SWAP data.
21. A host, comprising: a host controller, wherein,
the host controller is configured to:
determining the data type of target data to be written into the storage equipment; the data type comprises a first type or a second type;
generating a write command for the target data, the write command including a data type identification of the target data; the data type identification is used for identifying the first type or the second type;
and sending the write command to the storage device, wherein the write command is used for indicating the storage device to store the target data and the data type identifier.
22. The host of claim 21, wherein the host controller is further to:
judging whether the target data is any one of file system metadata, a high-frequency access database or SWAP data of an exchange area;
if yes, determining the target data as the first type of data;
if not, the target data is judged to be the second type of data, and the storage performance requirement of the first type of data is higher than that of the second type of data.
23. The host of claim 21 or 22, wherein the host controller is further configured to:
sending a read command for the target data to the storage device;
if the target data is the first type, reading the target data and the data type identifier from the first storage area;
and if the target data is of the second type, reading the target data and the data type identifier from the second storage area, wherein the storage performance requirement of the first type of data is higher than that of the second type of data.
24. The host of claim 23, wherein the host further comprises an internal memory, the internal memory being a volatile memory;
the host controller is further configured to: and storing the read target data and the data type identification into the internal memory.
25. An electronic device, comprising: a host and a storage device coupled to the host;
the host is the host according to any one of claims 22-24;
the storage device is according to any one of claims 13-21.
26. A data storage method applied to an electronic device, wherein the electronic device includes an internal memory and an external memory, the internal memory includes a normal partition and a SWAP partition, the external memory includes a first storage area and a second storage area, and the storage performance of the first storage area is better than that of the second storage area, the method includes:
the electronic equipment runs N application programs, and running data of the N application programs is stored in the internal memory; the N application programs comprise first application programs, the first application programs are application programs operated in a foreground, the first application programs occupy partial space of the common partition, and N is a positive integer;
in response to a start operation of a second application, the electronic device determining a remaining space of the normal partition and a remaining space of the SWAP partition;
if the remaining space of the ordinary partition and the remaining space of the SWAP partition are insufficient, determining the data of the SWAP partition as data of a first type, storing the data into the first storage area, and emptying the SWAP partition; compressing the running data of M application programs in the N application programs, storing the compressed running data to the SWAP partition, and releasing the common partition occupied by the M application programs; wherein the M applications comprise the first application;
foreground running the second application; the second application program occupies part or all of the common partitions occupied by the released M application programs;
responding to the starting operation of the first application program, and reading the running data of the first application program from the SWAP partition;
decompressing the running data of the first application program, and running the first application program in a foreground.
27. The method of claim 26, wherein prior to said reading the operating data of the first application from the SWAP partition, the method further comprises:
searching the running data of the first application program in the first storage area;
and reading the running data containing the first application program in the first storage area into the SWAP partition.
28. The method of claim 26 or 27, wherein the method further comprises:
and selecting M application programs with high priority levels from the N application programs to determine the M application programs, and releasing the space of the common partition occupied by the L application programs with low priority levels in the N application programs.
29. The method of any of claims 26-28, wherein determining the SWAP partition data to be a first type of data to store in the first memory region comprises:
generating a write command for data of the SWAP partition, the write command including a data type identification of a first type of data of the SWAP partition;
and storing the data of the SWAP partition and the data type identifier of the first type into the first storage area according to the write command.
30. The method of any one of claims 26-29, further comprising:
if the storage space of the first storage area meets the recovery condition, the data of the first type is kept in the first storage area, and the data of the second type is recovered to the second storage area; wherein the first type of data has a higher storage performance requirement than the second type of data.
31. The method of claim 30, wherein said storing said SWAP partition data and said first type of data type identification in said first memory area comprises: storing the data of the SWAP partition and the data type identification of the first type into a first storage Block in the first storage area;
if the storage space of the first storage area meets the recycling condition, the step of retaining the first type of data in the first storage area comprises:
and if the storage space of the first storage area meets the recovery condition, moving the data of the SWAP partition and the data type identifier of the first type from a first storage Block in the first storage area to a second Block in the first storage area.
32. An electronic device comprising a processor and a memory, wherein the memory is configured to store program code, and wherein the processor is configured to invoke the program code stored by the memory to cause the electronic device to perform the method of any of claims 26 to 31.
33. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a storage device, implements the method of any of the preceding claims 1-8.
34. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a host, implements the method of any of the preceding claims 9-12.
35. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which when executed by an electronic device implements the method of any of the preceding claims 26-31.
36. A computer program, characterized in that the computer program comprises instructions which, when executed by a storage device, cause the storage device to carry out the method according to any one of claims 1-8.
37. A computer program, characterized in that the computer program comprises instructions which, when executed by a host, cause the host to carry out the method according to any one of claims 9-12.
38. A computer program comprising instructions for causing an electronic device to perform the method of any one of claims 26-31 when the computer program is executed by a host computer.
CN202010371512.4A 2020-04-30 2020-04-30 Data storage method and related equipment Pending CN113590501A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010371512.4A CN113590501A (en) 2020-04-30 2020-04-30 Data storage method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010371512.4A CN113590501A (en) 2020-04-30 2020-04-30 Data storage method and related equipment

Publications (1)

Publication Number Publication Date
CN113590501A true CN113590501A (en) 2021-11-02

Family

ID=78237913

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010371512.4A Pending CN113590501A (en) 2020-04-30 2020-04-30 Data storage method and related equipment

Country Status (1)

Country Link
CN (1) CN113590501A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114153643A (en) * 2021-11-30 2022-03-08 联想(北京)有限公司 Data processing method and device
CN116450059A (en) * 2023-06-20 2023-07-18 宁德时代新能源科技股份有限公司 Data management method, apparatus, electronic device, storage medium, and program product
CN116775507A (en) * 2023-08-23 2023-09-19 四川云海芯科微电子科技有限公司 Hardware acceleration block selection method and device in garbage collection of solid state disk controller
CN117369735A (en) * 2023-12-08 2024-01-09 荣耀终端有限公司 Data storage method, electronic device and storage medium
CN117687570A (en) * 2023-11-17 2024-03-12 鸿秦(北京)科技有限公司 Self-adaptive method for read-write service in solid state disk

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105677257A (en) * 2016-02-04 2016-06-15 联想(北京)有限公司 Data storage method and electronic equipment
CN107807796A (en) * 2017-11-17 2018-03-16 北京联想超融合科技有限公司 A kind of data hierarchy method, terminal and system based on super fusion storage system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105677257A (en) * 2016-02-04 2016-06-15 联想(北京)有限公司 Data storage method and electronic equipment
CN107807796A (en) * 2017-11-17 2018-03-16 北京联想超融合科技有限公司 A kind of data hierarchy method, terminal and system based on super fusion storage system

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114153643A (en) * 2021-11-30 2022-03-08 联想(北京)有限公司 Data processing method and device
CN116450059A (en) * 2023-06-20 2023-07-18 宁德时代新能源科技股份有限公司 Data management method, apparatus, electronic device, storage medium, and program product
CN116450059B (en) * 2023-06-20 2024-04-12 宁德时代新能源科技股份有限公司 Data management method, apparatus, electronic device, storage medium, and program product
CN116775507A (en) * 2023-08-23 2023-09-19 四川云海芯科微电子科技有限公司 Hardware acceleration block selection method and device in garbage collection of solid state disk controller
CN116775507B (en) * 2023-08-23 2023-10-20 四川云海芯科微电子科技有限公司 Hardware acceleration block selection method and device in garbage collection of solid state disk controller
CN117687570A (en) * 2023-11-17 2024-03-12 鸿秦(北京)科技有限公司 Self-adaptive method for read-write service in solid state disk
CN117369735A (en) * 2023-12-08 2024-01-09 荣耀终端有限公司 Data storage method, electronic device and storage medium
CN117369735B (en) * 2023-12-08 2024-05-10 荣耀终端有限公司 Data storage method, electronic device and storage medium

Similar Documents

Publication Publication Date Title
US11829601B2 (en) Extended utilization area for a memory device
US11782647B2 (en) Managing operational state data in memory module
CN111506262B (en) Storage system, file storage and reading method and terminal equipment
CN113590501A (en) Data storage method and related equipment
US20170177497A1 (en) Compressed caching of a logical-to-physical address table for nand-type flash memory
TWI708144B (en) Apparatus and computer program product for performing operations to namespaces of a flash memory device
KR20130031046A (en) Flash memory device and data manage method thererof
US9164804B2 (en) Virtual memory module
CN114840450B (en) Storage space arrangement method and electronic equipment
US8131918B2 (en) Method and terminal for demand paging at least one of code and data requiring real-time response
WO2023065815A1 (en) File system deployment method and apparatus, file system extension method and apparatus, device, and storage medium
CN112306906A (en) Storage device, storage system including the same, and method of operating the same
CN115495020A (en) File processing method and device, electronic equipment and readable storage medium
KR101270777B1 (en) System and method for writing data using a PRAM in a device based on input-output of block unit
CN117369735B (en) Data storage method, electronic device and storage medium
CN114676092A (en) File management method and related equipment
CN114741205B (en) Anonymous page recovery method and electronic device
CN117707639B (en) Application start acceleration method, electronic device and storage medium
KR102210536B1 (en) Data storage system of on-volatile memory apparatus and method of the same
CN116662222A (en) Cache management method and related equipment
CN116954511A (en) Storage processing method, electronic device, and readable storage medium
CN117396859A (en) Data processing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination